May 2020
Intermediate to advanced
404 pages
10h 52m
English
Create a new file in the working directory and name it flask_app.py. This file will be the one that handles all requests made to the server. Put the following code in the file:
from flask import Flaskapp = Flask(__name__)@app.route("/")def index(): return "Hello World!"if __name__ == "__main__": app.run(host='0.0.0.0', port=80)
The preceding code first imports the necessary modules into the script. Then, it sets the app as the Flask server object and defines the index function with a directive of handling all the requests made to the "/" address, regardless of the type of request. At the end of the script, the run() method of the Flask object app is used to bind the script to a specified port on the system. ...
Read now
Unlock full access