Base Flask Setup
This is a base Flask/uWSGI/nginx setup, useful as a skeleton for building simple web apps from. This is meant to be used for websites, as opposed to pure JSON sites which would be better developed using a different language or framework (e.g. sanic).
- Developed specifically for Python 3
- Minimal but up-to-date python dependencies
- 100% test coverage
- No issues from Code Climate
- PEP8 compliant
- Documented setup and usage procedures
- Includes setting up secure and fast nginx/uwsgi in production
- Docker support
Modify and run
bin/scaffold.sh to create a copy of base-flask for your
project needs, then run
bin/setup.sh to set up the host.
A CDN like cloudflare can also be added on to boost speed. A good cloudflare setup would be to use full SSL encryption and to install an origin certificate so that requests are encrypted end-to-end.
mkvirtualenv app -p python3.5 pip install -r requirements.txt pip install -r requirements-test.txt ln -s .env.development .env
Spinning up the server:
mypy app --ignore-missing-imports coverage run -m unittest discover
This repo uses:
# Switch to python 3 pyenv local 3.5 pip install -r requirements.txt pip install -r requirements-test.txt ln -s .env.development .env # Test flake8 coverage run -m unittest discover coverage report codeclimate-test-reporter # Deployment ssh example.com website/bin/deploy.sh
Building and starting the docker container
docker build -t $PROJECT_NAME:test . docker run -t -i -p 127.0.0.1:5000:5000 $PROJECT_NAME:test