export FLASK_APP=hello export FLASK_ENV=development flask run
Here is what the above code is Doing:
1. We import Flask and render_template.
2. We create an instance of the Flask class. The first argument is the name of the application’s module or package. If you are using a single module (as in this example), you should use __name__ because depending on if it’s started as application or imported as module the name will be different (‘__main__’ versus the actual import name). This is needed so that Flask knows where to look for templates, static files, and so on. For more information have a look at the Flask documentation.
3. We create a function called hello which returns the string ‘Hello, World!’
4. We create a route for the URL / which is bound to the hello function.
5. We run the application using the run() method.