/flask-seed

Flask Seed

Primary LanguagePythonMIT LicenseMIT

Flask Seed

MIT licensed Build Status


Flask seed project...

Quick Start

Basic Setup

  1. Install pipenv
    $ pip install pipenv
  2. Create and activate virtual environment
    $ cd <project_dir>
    $ pipenv shell
  3. Install python packages
    $ pipenv install
    $ pipenv install --dev

Set Environment Variables

Set environment variables necessary to run Flask. NOTE: This is only necessary if executing flask directly and not through bootstrap.sh.

$ export FLASK_APP=autoapp.py
$ export FLASK_APP_CONFIG=local

NOTE: You will need to set these two environment variables every time you re-activate the shell

TODO: Implement something like python-dotenv

Create DB

This will create an initial SQLite database based on latest migrations.

$ flask db upgrade

Run the Application

A bootstrap.sh BASH script has been created to help run the application.

Local with debug mode:

$ ./bootstrap.sh -e local -d

Prod using Gunicorn

$ ./bootstrap.sh -e prod -w

Testing

Flask click command (w/ coverage):

$ flask test

Pytest without coverage:

$ pytest

Pytest with coverage:

$ pytest --cov=app

Deactivating an active python virtual environment

Assuming your current shell has an activate virtual environment (denoted by something similar to (flask-seed-ETuCx1xA) within the shell), make sure to deactivate upon completion.

$ exit

Custom Flask commands

Various custom click commands have been defined within the commands module. A full list of flask commands can be found by running...

$ flask --help

clean      Remove *.pyc and *.pyo files recursively starting at current directory.  
create_db  Create initial database.  
db         Perform database migrations.  
lint       Lint and check code style with flake8 and isort.  
run        Runs a development server.  
shell      Runs a shell in the app context.  
urls       Display all of the url matching routes for the project.  

$ flask urls
Rule               Endpoint
----------------------------------
/api/v1/expenses/  api.v1.expenses
/api/v1/incomes/   api.v1.incomes