from flask import Flask app = Flask(__name__) @app.route("/") def index(): return "Hello!
" if __name__ == "__main__": from waitress import serve serve(app, host="0.0.0.0", port=8080)
Here is what the above code is Doing:
1. We’re creating a new Flask object.
2. We’re using the route decorator to tell Flask what URL should trigger our function.
3. We’re defining a function, index(), which is going to return the string “Hello, world!”.
4. We’re adding a bit of code at the bottom of the script to make sure that the application is run when the script is executed.