Flask/Hello World

This lesson shows how to display Hello world using Flask.

Readings edit

  1. Wikipedia: Flask (web framework)

Multimedia edit

Activities edit

  1. Create or modify the Flask application page.
    • On Repl.it, modify main.py to include the following code. On your own system, create a new file named app.py with the following code.
      import flask

      app = flask.Flask(__name__)

      @app.route('/')
      def root():
          return "Hello world!"

      if __name__ == "__main__":
          app.run(host='0.0.0.0', port=5000)
  2. Run the program. On your own system use the following command in a terminal window in the same folder as your app.py file:
    flask run
  3. Refresh the output window or open a browser window to http://localhost:5000.
  4. Stop the program.

References edit