Skip to main content

A Flask-based framework for easy REST API projects building.

Project description

Flask-RESTBuilder

Flask-RESTBuilder is a mircroframework based on Flask and some Flask’s extensions. It’s aimed to make it easier to build a RESTful API project in Flask.

Installing

Install and update by pip:

pip install flask_restbuilder

Example

About Project

Use command flask_restbuilder start to create a project:

path/to/project: flask_restbuilder start
What is your project's name? [myproject]: myproject
Where you want to create?(empty to current dir) [path/to/project]:
Your project's modules(use whitespace to split) [mymodule]: app1 app2
Need swagger support?(y/n) [y]:

Follow the guidance and finish the questions below, you will get a directory (The project directory is based on src mode):

myproject
├─ .gitignore
├─ CHANGES.rst
├─ README.rst
└─ src
    └─ myproject
        ├─ config.py
        ├─ manage.py
        ├─ app
        │   ├─ __init__.py
        │   ├─ api
        │   │   ├─ app1.py
        │   │   ├─ app2.py
        │   │   └─ __init__.py
        │   ├─ app1
        │   │   ├─ models.py
        │   │   ├─ routes.py
        │   │   └─ __init__.py
        │   └─ app2
        │       ├─ models.py
        │       ├─ routes.py
        │       └─ __init__.py
        └─ extension
            └─ mysql.py

About API

Create your API views like:

from flask_restbuilder import RESTful

class MyAPI(RESTful):

    def __init__(self):
        self.parser.add_argument('arg')
        self.parse_arguments()

    def get(self):
        result = self.init_response(data=self.args)
        return result

self.parser is an instance of flask_restful.reqparse.RequestParser, use add_argument the same way. Use self.parse_arguments to make self.args = self.parser.parse_args()

About Error

There some basic errors in flask_restbuilder.exceptions. Customize your exceptions from flask_restbuilder.BaseError:

from flask_restbuilder import BaseError

class MyError(BaseError):
    code = 12345
    message = 'my error message'

About Database

Flask_SQLAlchemy is equipped. You can see in extension/mysql.py and freely edit any basic options.

Thanks to

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-RESTBuilder-0.1.0.tar.gz (10.7 kB view hashes)

Uploaded Source

Built Distribution

Flask_RESTBuilder-0.1.0-py3-none-any.whl (24.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page