How to Create an App
Use Flask to create a basic app in Python
Introduction:
In the next five minutes, you will create your own working app in Flask using Python.
Instructions:
1. REPO
Go to Github, and make a new repo for your project, so that it can be saved to the web.
Now, clone the repo to your local machine, so you can edit it and push changes.
2. VENV
Create and activate a virtual environment for this project.
If do not already have virtualenv, you can install it from the command line using pip, as follows.
pip install virtualenv
Make sure it is really installed by checking the version. Type into the terminal:
virtualenv --version
Now create the virtual environment by typing into the command line:
virtualenv my-venv
3. APP
Create a new file called app.py
It should contain this:
# app.py
from flask import Flaskapp = Flask(__name__)@app.route('/')
def hello():
return 'Hello, World!'
4. RUN
Run your app on the local server.
Type these three commands into the terminal:
set FLASK_APP=flaskr
set FLASK_ENV=development
flask run
Conclusion:
Congrats! You have created from scratch your first functioning app using Python and Flask!