Skip to main content

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

Metadata

Release files for Flask-RESTBuilder 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Flask-RESTBuilder 0.1.0
File Size Uploaded
Flask-RESTBuilder-0.1.0.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Flask-RESTBuilder 0.1.0
File Interpreter ABI Platform
Flask_RESTBuilder-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.8 kB

Release files / Flask-RESTBuilder-0.1.0.tar.gz

Download URL Flask-RESTBuilder-0.1.0.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
754bb1cc4080611ff6e2dd41d7f692653edd700d752430dbea342ca8927011bd
BLAKE2b-256 checksum
How to use checksums
6a43c600ef47c21c48ad7a788a2c0302469c2567f50957590fb3d25c0e92d33a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.48.2 CPython/3.8.0

Release files / Flask_RESTBuilder-0.1.0-py3-none-any.whl

Download URL Flask_RESTBuilder-0.1.0-py3-none-any.whl
Size 24.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a74e291faf051dd08f812983dc4e92b168bea2d6fd39d5a94da7e2c6e93524a
BLAKE2b-256 checksum
How to use checksums
0fdbc4ee87e1400d2acc9f895d563708558522e8cb076b96cf53bc9142a9e7e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.48.2 CPython/3.8.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page