Code from Anthony Herbert's Digitalocean article "How To Add Authentication to Your App with Flask-Login" with minor changes as follows:
- Tabs for indentation instead of spaces. I know PEP-8 styleguide prefers spaces, however I find this a mind-numbingly bad default and will gleefully thumb my nose at it whenever I get the chance; tabs are more flexible.
- Step 6 changes that will be noted below
- remove extraneous spaces around tags in the template documents
- reorganization of the navbar links in step 10 to prevent the need for multiple is_authenticated ifs
Each step is a seperate branch, with code appearing as it should at the end of each step; the main branch is the finished tutorial, plus the addition of requirements.txt
to install dependancies through pip.
included in the base of the project from Step 6 onwards is an extra file, dbcreate.py, that is a 2 line script that should be run to set up the database, instead of running commands from a python shell. This is included for convenience, in order to have all the code needed to run this project in this repo, as well as to fix an error in the instructions: models must be imported on line 1, and this is missing from the tutorial. This file should be run by issuing
python3 createdb.py
in the directory the flask-login-tutorial
directory.
- Checkout the master repository
- install requirements with
pip install -r requirements.txt
- run createdb as indicated earlier
- set enviornment variables as follows:
export FLASK_APP=project
andexport FLASK_DEBUG=1
- run the dev server with
flask run