Simple Flask API Boilerplate enhanced with JWT authentication, OAuth via GitHub, SqlAlchemy, SQLite persistence, and deployment scripts via Docker. It has all the ready-to-use bare minimum essentials.
Features:
- โ
Up-to-date dependencies
- โ
API Definition - the unified API structure implemented by this server
- โ
API powered by
Flask-restX
- โ
JWT Authentication (login, logout, register) via Flask-jwt_extended
- ๐
OAuth for Github
- โ
Docker,
Unitary tests
Can be used with other React Starters for a complete Full-Stack experience:

โจ Quick Start in Docker
Get the code
$ git clone https://github.com/app-generator/api-server-flask.git
$ cd api-server-flask
Start the app in Docker
$ docker-compose up --build
The API server will start using the PORT 5000.
โจ Table of Contents
- Getting Started
- Project Structure
- Modules
- Testing
โจ How to use the code
Step #1 - Clone the project
$ git clone https://github.com/app-generator/api-server-flask.git
$ cd api-server-flask
Step #2 - create virtual environment using python3 and activate it (keep it outside our project directory)
$ # Virtualenv modules installation (Unix based systems)
$ virtualenv env
$ source env/bin/activate
$
$ # Virtualenv modules installation (Windows based systems)
$ # virtualenv env
$ # .\env\Scripts\activate
Step #3 - Install dependencies in virtualenv
$ pip install -r requirements.txt
Step #4 - setup flask command for our app
$ export FLASK_APP=run.py
$ export FLASK_ENV=development
For Windows-based systems
$ (Windows CMD) set FLASK_APP=run.py
$ (Windows CMD) set FLASK_ENV=development
$
$ (Powershell) $env:FLASK_APP = ".\run.py"
$ (Powershell) $env:FLASK_ENV = "development"
Step #5 - Create a new .env file using sample env.sample
The meaning of each variable can be found below:
DEBUG: if True the app runs in develoment mode
- For production value
False should be used
SECRET_KEY: used in assets management
GITHUB_CLIENT_ID: For GitHub social login
GITHUB_SECRET_KEY: For GitHub social login
Step #6 - start test APIs server at localhost:5000
$ flask run
Use the API via POSTMAN or Swagger Dashboard.
โจ Project Structure
api-server-flask/
โโโ api
โย ย โโโ config.py
โย ย โโโ __init__.py
โย ย โโโ models.py
โย ย โโโ routes.py
โโโ Dockerfile
โโโ README.md
โโโ requirements.txt
โโโ run.py
โโโ tests.py
โจ API
For a fast set up, use this POSTMAN file: api_sample
Register - api/users/register (POST request)
POST api/users/register
Content-Type: application/json
{
"username":"test",
"password":"pass",
"email":"test@appseed.us"
}
Login - api/users/login (POST request)
POST /api/users/login
Content-Type: application/json
{
"password":"pass",
"email":"test@appseed.us"
}
Logout - api/users/logout (POST request)
POST api/users/logout
Content-Type: application/json
authorization: JWT_TOKEN (returned by Login request)
{
"token":"JWT_TOKEN"
}
โจ Testing
Run tests using pytest tests.py
Flask API Server - provided by AppSeed