Base Flask/uWSGI/nginx setup
MIT License
This is a base Flask/Gunicorn/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).
These repositories are based on base-flask:
Modify and run baseflask/scaffold.sh
to create a copy of base-flask for your
project needs, then run bin/setup.sh
to set up the host.
Base-flask is designed to work with a minimally sized AWS EC2 or DigitalOcean instance, running a modern version of Ubuntu or Debian.
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.
Using python venv and optionally direnv
python3.12 -m venv env
printf "source env/bin/activate\nunset PS1\n" > .envrc
direnv allow
pip install -e .[test]
ln -s .env.development .env
npm install
# Install shellcheck
# brew install shellcheck
# sudo apt-get install shellcheck
npm run build:dev
python app/serve.py
ruff check .
mypy .
shellcheck --exclude=SC1091 bin/*.sh
coverage run -m unittest discover
npm test
This repo uses:
# Switch to python 3
pyenv local 3.12
pip install -e .[test]
ln -s .env.development .env
# Test
ruff check .
mypy .
shellcheck --exclude=SC1091 bin/*.sh
coverage run -m unittest discover
coverage report
codeclimate-test-reporter
npm test
# Deployment
ssh example.com website/bin/deploy.sh
docker build -t $PROJECT_NAME:test .
docker run -t -i -p 127.0.0.1:$INTERNAL_PORT:5000 $PROJECT_NAME:test
Run this once on a new server to set up the web app:
bin/setup.sh
Run this every time for a new commit to the repository:
bin/deploy.sh