Skip to content

RayeRen/flask-foundation

Repository files navigation

Flask Foundation

Based on https://github.com/JackStouffer/Flask-Foundation. Compatible with Flask 1.0

Dependencies

  • Python 3+
  • Flask 1.0+
  • mysql
  • all packages in requirements.txt

Quick Start Development

Configure the .env file

  1. cp .env.example .env
  2. Modify .env

Mysql Service

  1. Install mysql server and client
  2. Enable the mysql service

Install Dependencies

pip install -U -r requirement.txt

Run Unittests

py.test tests 

You will see the following summary after all tests finished.

==================== 7 passed, 21 warnings in 1.88 seconds ====================

Create Dev Database

flask db init
flask db migrate
flask db upgrade

Run Dev Server

flask run

Migrate Database Schema

flask db migrate
flask db upgrade

Run Prod Server

  1. Switch the config to Prod mode in .env
flask db init
flask run

Deploy with Nginx and Uwsgi

Intall Nginx and Uwsgi

apt install nginx
conda install -c conda-forge uwsgi libiconv

Increase Max Listening Connections

echo net.core.somaxconn= 4000 >  /etc/sysctl.conf && sysctl -p

Configure

cp nginx/nginx.conf.example nginx/nginx.conf
vi nginx.conf # modify the config file
ln -s $PWD/nginx/nginx.conf.example /etc/nginx/conf.d/MY_APP.conf

cp uwsgi.ini.example uwsgi.ini
vi uwsgi.ini # modify the config file

Start UWSGI

uwsgi --ini uwsgi.ini

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages