nmccartney / flask-boilerplate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flask Boilerplate

Dependencies

Quick Start

Start the app in dev mode

$ task build-dev
$ task run-dev

OR - Start the app in dev mode while watching files

$ task build-watch
$ task watch-dev

The API server will start using the PORT 5000.

Table of Contents

  1. Getting Started
  2. Project Structure
  3. Modules
  4. Testing

How to use the code (Work in progress)

Step #1 - Install dependencies in virtualenv

$ pip install -r requirements.txt

Step #2 - setup flask command for our app

$ export FLASK_APP=run.py
$ export FLASK_ENV=development

Or 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 #3 - start test APIs server at localhost:5000

$ flask run

API

Register - api/users/register (POST request)

POST api/users/register
Content-Type: application/json

{
    "username":"test",
    "password":"p@$$w0rd",
    "email":"test@domain.io"
}

Login - api/users/login (POST request)

POST /api/users/login
Content-Type: application/json

{
    "password":"p@$$w0rd",
    "email":"test@domain.io"
}

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


About


Languages

Language:Python 92.2%Language:Dockerfile 7.6%Language:Shell 0.2%