Skip to content

Kaspary/simple-flask-api-template

Repository files navigation

Flask Rest API Template

GitHub last commit

About The Project

Simple Rest API flask template, to start build API.

Built With

Getting Started

Prerequisites

Installation

  1. Cloning this repository.

    $ git clone https://github.com/Kaspary/simple-flask-api-template.git
  2. Creating and activate a python virtual environment, with your favorite tool.

    $ virtualenv env && source env/bin/activate
  3. Install all dependencies.

    $ pip install -r requirements.txt
  4. Creating a file named .env, into the project (using example.env as example).

  5. Run project

    $ flask run

Database migration

  1. Run migration to create database schema.
    $ flask db init

Usage

User cli manager

Commands

  • flask user create: Create new user; Examples:
    $ flask user create my_user
    $ flask user create my_admin_user --admin
    $ flask user create my_new_user --auto-pass
  • flask user list: List all users:
    • Example:
    $ flask user list
  • flask user delete: Delete a user by id;
    • Example:
    $ flask user delete 1
  • flask user activation: Set a user as active by id;
    • Example:
    $ flask user activation 1
  • flask user newpassword: Set new password to user by id.
    • Example:
    $ flask user newpassword 1
    $ flask user newpassword 1 --auto-pass

Flags

  • --admin: Set user as admin on create command;
    $ flask user create my_user --admin
  • --auto-pass: Using to generete a random pass on newpassword or create command.
    $ flask user create my_user --auto-pass

Run project

After instalation, run this command:

$ flask run

Access API on http://127.0.0.1:5000.

Using API

To understed how to using the API, access http://127.0.0.1:5000/documentation. Postman collection is accessible on http://127.0.0.1:5000/documentation/postman.

Documentation

Web Documentation is generatig using Docgen project.

(back to top)

About

A simple template to flask api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published