Metadata-Version: 2.1
Name: Flask-RESTBuilder
Version: 0.1.0
Summary: A Flask-based framework for easy REST API projects building.
Home-page: https://github.com/TnTomato/flask_restbuilder
Author: TnTomato
Author-email: 474093103@qq.com
Maintainer: TnTomato
License: BSD-3-Clause
Project-URL: Code, https://github.com/TnTomato/flask_restbuilder
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Framework :: Flask
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Requires-Python: >=3.8
Requires-Dist: aniso8601 (>=8.0.0)
Requires-Dist: attrs (>=20.1.0)
Requires-Dist: click (>=7.1.2)
Requires-Dist: flasgger (>=0.9.5)
Requires-Dist: Flask (>=1.1.2)
Requires-Dist: Flask-RESTful (>=0.3.8)
Requires-Dist: Flask-Script (>=2.0.6)
Requires-Dist: Flask-SQLAlchemy (>=2.4.4)
Requires-Dist: itsdangerous (>=1.1.0)
Requires-Dist: Jinja2 (>=2.11.2)
Requires-Dist: jsonschema (>=3.2.0)
Requires-Dist: MarkupSafe (>=1.1.1)
Requires-Dist: mistune (>=0.8.4)
Requires-Dist: pymongo (>=3.11.0)
Requires-Dist: pyrsistent (>=0.16.0)
Requires-Dist: pytz (>=2020.1)
Requires-Dist: PyYAML (>=5.3.1)
Requires-Dist: six (>=1.15.0)
Requires-Dist: SQLAlchemy (>=1.3.19)
Requires-Dist: Werkzeug (>=1.0.1)

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:

.. code-block:: text

    pip install flask_restbuilder

Example
=======

About Project
-------------

Use command ``flask_restbuilder start`` to create a project:

.. code-block:: text

    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**):

.. code-block:: text

    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:

.. code-block:: python

    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``:

.. code-block:: python

    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
=========

    - `Flask`_
    - `Jinja`_
    - `Click`_
    - `Flask-RESTful`_
    - `Flask-SQLAlchemy`_
    - `Flask-Script`_
    - `Flasgger`_

.. _Flask: https://github.com/pallets/flask
.. _Jinja: https://github.com/pallets/jinja
.. _Click: https://github.com/pallets/click
.. _Flask-RESTful: https://github.com/flask-restful/flask-restful
.. _Flask-SQLAlchemy: https://github.com/pallets/flask-sqlalchemy
.. _Flask-Script: https://github.com/smurfix/flask-script
.. _Flasgger: https://github.com/flasgger/flasgger

