Flask/Run Flask Online

This lesson shows how to run Flask online using Repl.it.

Readings

edit
  1. Wikipedia: Flask (web framework)
  2. Repl.it: Flask Tutorial Part 1

Multimedia

edit

Activities

edit
  1. Run a Repl.it Python environment.
  2. Add the Flask package.
    • Select Packages on the left.
    • Search for Flask.
    • Add Flask.
  3. Display Hello world!
    • Add the following code to main.py:
      import flask

      app = flask.Flask(__name__)

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

      if __name__ == "__main__":
          app.run(host='0.0.0.0', port=5000)
    • Run the program.
    • Refresh the output window.
    • Stop the program.
  4. Modify Flask output.
    • Customize the return line to display Hello name!, where name is your name.
    • Run the program and refresh the output window to see your changes.
    • Stop the program.

References

edit