Flask/Hello World
Appearance
< Flask
This lesson shows how to display Hello world using Flask.
Readings
[edit | edit source]Multimedia
[edit | edit source]Activities
[edit | edit source]- 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 namedapp.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)
- On Repl.it, modify
- 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
- Refresh the output window or open a browser window to http://localhost:5000.
- Stop the program.