I’m going to show you how to make a simple Flask app.
You first go to the folder of your project.
Next, you create a virtual environment. In this case, I’m naming the virtual environment “virtual”. Virtual environments let you install python specifically for a project letting you use whatever configuration or version you need.
Then, I install flask. I’m using the pip in “virtual\scripts” to make sure I’m installing flask to the python in my virtual environment.
#! python3 # simpleapp.py from flask import Flask app = Flask(__name__) @app.route('/') def home(): return 'Hello' app.run()
I create a “simpleapp.py” file and added it to my project folder. In line 6, an app object is instantiated from the Flask class. The decorator invocation line registers a view function for a given URL rule. The function is home in this case. The last line runs the app.
Finally, we can get our app running by executing the “simpleapp.py” file through the python in our virtual environment. By default, this runs the app on the localhost.