Environment Set Up
1. install python and pip3
2. install virtual environment tool
pip3 install virtualenv
3. make a new directory and enter it to build the venv and activate it.
virtualenv --no-site-packages venv
source venv/bin/activate
4. install flask
source venv/bin/activate
5. write a python route script and set env variables
export FLASK_APP=flaskexample.py
# This will set flask to the main script to be run,
# so that we can use "flask run" to run the project
export FLASK_DEBUG=1
# This will allow us to refresh the web page without rerun the script
6. without set the env variables, we can also achieve 5 by running the python script with a main function in it.
if __name__ == '__main__':
app.run(debug=True)
7. to present a user interface, we need forms. A Form’s elements such as text input, radio, select etc. can be used appropriately. Flask-WTF is an useful lib for doing this, and can also render the forms in many styles. To install this package just use the following command in the virtual environment you built.
pip install flask-WTF