Flask/Run Flask Online
Appearance
< Flask
This lesson shows how to run Flask online using Repl.it.
Readings
[edit | edit source]Multimedia
[edit | edit source]Activities
[edit | edit source]- Run a Repl.it Python environment.
- Open Repl.it: Python3 in a new tab or new window.
- Add the Flask package.
- Select Packages on the left.
- Search for Flask.
- Add Flask.
- 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.
- Add the following code to main.py:
- 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.
- Customize the return line to display