Git Product home page Git Product logo

flask-restplus_postgresql_boilerplate's Introduction

Flask Base

Python

My template base to build Flask RESTful APIs using Flask RESTPlus, JWT Extended and PyMongo.

You can just clone this repo and start to create/customize your own RESTful API using this code as your template base :)

Localhost

Installing

pip3 install -r requirements.txt

Usage

export MONGO_URI="mongodb://<your_mongo_host>:27017/<your_database>"
export JWT_SECRET_KEY="<randomic_key>"
python3 entrypoint.py

Docker

Installing

docker build -t flask-app --target develop .

Usage

docker run -d \
-p 5000:5000 \
-e MONGO_URI="mongodb://<your_mongo_host>:<your_mongo_port>/<your_mongo_database>" \
-e JWT_SECRET_KEY="<your_randomic_key>" \
flask-app

Swagger

After the application goes up, open your browser on localhost:5000/api/v1/docs to see the self-documented interactive API.

Project Structure

The project structure is based on the official Scaling your project doc with some adaptations (e.g v1 folder to agroup versioned resources).

.
├── app
│   ├── helpers
│   │   ├── __init__.py
│   │   ├── parsers.py
│   │   └── password.py
│   ├── __init__.py
│   └── v1
│       ├── __init__.py
│       └── blueprints
│           ├── auth
│           │   ├── __init__.py
│           │   ├── routes.py
│           │   └── serializers.py
│           ├── __init__.py
│           └── users
│               ├── __init__.py
│               ├── services.py
│               ├── serializers.py
│               └── routes.py
├── config.py
├── Dockerfile
├── LICENSE
├── README.md
├── requirements.txt
├── entrypoint.py
└── entrypoint.sh

Folders

  • app - All the RESTful API implementation is here.
  • app/helpers - Useful function/class helpers for all modules.
  • app/v1 - Resource agroupment for all v1 Namespaces.
  • app/v1/blueprints - All v1 resources are implemented here.

Files

  • app/__init__.py - The Flask Application factory (create_app()) and it's configuration are done here. Your Blueprints are registered here.
  • app/v1/__init__.py - The Flask RESTPlus API is created here with the versioned Blueprint (e.g v1). Your Namespaces are registered here.
  • config.py - Config file for envs, global config vars and so on.
  • Dockerfile - Dockerfile used to build a Docker image (using Docker Multistage Build)
  • LICENSE - MIT License, i.e. you are free to do whatever is needed with the given code with no limits.
  • .dockerignore - Lists files and directories which should be ignored while Docker build process.
  • .gitignore - Lists files and directories which should not be added to git repository.
  • requirements.txt - All project dependencies.
  • entrypoint.py - The application entrypoint.
  • entrypoint.sh - Starting script before application

License

This project is licensed under the MIT License - see the LICENSE file for details.

flask-restplus_postgresql_boilerplate's People

Contributors

duanribeiro avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.