[go: nahoru, domu]

Skip to content

unofficialopensource-knit/Flask-REST-Server-Template

 
 

Repository files navigation

Flask-REST-Server-Template

Build Status GitHub top language codecov Updates Python 3 GitHub code size in bytes GitHub issues GitHub pull requests GitHub GitHub last commit

Info

This is a template for spinning up a REST server in Flask for API first development. Use this repo as a template repo.

Dependencies

The server is tested in our travis account for following versions of Python

  • 3.6
  • 3.7
  • 3.7-dev
  • 3.8-dev

The server dependencies are specified based according to the environment.

  • Production level dependencies are defined in requirements/prod.txt.
  • Development level dependencies are defined in requirements/dev.txt.
  • Testing level dependencies are defined in requirements/test.txt.

Docker

The image is pushed to dockerhub {$LINK}, every push to git repository triggers a new build at the dockerhub.

  • To build the image after modifications, run
    $ docker build -t {$IMAGE}:{$TAG} .
    
  • To run the container after the image has build successfully, run
    $ docker run -it -d -p {$EXTERNAL_PORT}:8000 {$IMAGE}:{$TAG}
    

Setup

To setup the dev env use the following commands.

$ python3 -m venv env
$ source env/bin/activate
(env) $ pip install --cache-dir .pip.cache/ --progress-bar emoji --upgrade pip setuptools
(env) $ pip install --cache-dir .pip.cache/ --progress-bar emoji --requirement requirements/dev.txt
(env) $ cp .env.example .env

To setup the db use the following commands.

(env) $ mysql -u user -p
mysql > CREATE DATABASE $DB;
mysql > CREATE USER '$USER'@'$HOST' IDENTIFIED BY $PASSWORD;
mysql > GRANT ALL PRIVILEGES ON * . * TO '$USER'@'$HOST';
mysql > FLUSH PRIVILEGES;
mysql > exit;
(env) $ python manage.py db init

To make a migration run the folowing commands

(env) $ python manage.py db migrate -m $MESSAGE
(env) $ python manage.py db upgrade

Contact

onlinejudge95

About

Template for REST server in flask

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 95.7%
  • Dockerfile 4.3%