Skip to content

phamngocquy/flask-api-boilerplate

 
 

Repository files navigation

FLASK RESTFUL API BOILERPLATE

Flask command line

List all commands

flask

Start api application

flask run

Config environment variables in .env file

  • Generate a good secret key:
python -c 'import os; print(os.urandom(24))'

More detail at: https://flask.palletsprojects.com/en/1.1.x/quickstart/#sessions

  • Create .env at project root folder with following content:
SECRET_KEY={generated secret}
DATABASE_URL=mysql+pymysql://user:password@host:port/database
TEST_DATABASE_URL=mysql+pymysql://user:password@host:port/database
ORIGIN_ALLOW_DOMAIN=*
DEPLOYMENT_ENV=dev
  • Available environments for DEPLOYMENT_ENV: dev | test | prod

Database migration

  1. Initiate a migration folder (once only)
flask db init
  1. Create migration script from detected changes in the model
flask db migrate --message 'initial database migration'
  1. Apply the migration script to the database
flask db upgrade

Viewing the app

Open the following url on your browser to view swagger documentation http://127.0.0.1:5000/

Contributing

If you want to contribute to this boilerplate, clone the repository and just start making pull requests.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.8%
  • Mako 1.2%