one small flask rest api factory
Project description
The initial idea is to be a Rest API factory, with the aim of making it easy to create from models defined using the SQLAlchemy ORM.
We still use pydantic to serialize objects and payloads.
Install
You can install using pip:
$ pip install flask-api-factory
You can install with the database driver you want to be supported by SQLAlchemy, but if you prefer, you can install the driver as an extra library, with the command:
$ pip install flask-api-factory[postgres]
This will install psycopg2 together with our library.
You can still install using poetry with the command:
$ poetry add flask-api-factory
A simple example
Having the Pet model already defined and the initialization of the Flask application already started, just use the following code:
from flask import Flask, Blueprint
from flask_api_factory import factory_api
from .models import Pet
from .serializers import PetSerializer
blueprint = Blueprint("pets", __name__, url_prefix="/pets")
def init_app(app: Flask) -> None:
app.register_blueprint(blueprint)
factory_api(blueprint, Pet, PetSerializer)
This way we will have a /pets endpoint capable of responding to all HTTP verbs. Consulting the documentation you can check other options for configurations and functionalities.
Roadmap
- Documentation;
-
openapi.jsongeneration mechanism; - A way to provide
Swaggerand/orRedoc; - Write unit tests.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flask_api_factory-0.2.3.tar.gz.
File metadata
- Download URL: flask_api_factory-0.2.3.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.10.10 Linux/5.15.0-1033-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d94017a5e388c1f9220951b5991ec2a5c1c8894566afda0484401f338df07285
|
|
| MD5 |
f471cee5209de5aa8484d09ae7f23347
|
|
| BLAKE2b-256 |
b0a85dd9cb8d2559960d7899ffafbd05ff166a84bafe42b776458b5181094f21
|
File details
Details for the file flask_api_factory-0.2.3-py3-none-any.whl.
File metadata
- Download URL: flask_api_factory-0.2.3-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.10.10 Linux/5.15.0-1033-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f6a1e811fd07ed1625264f6b9923b63d4798118fa8c970eee2691f83c84c8de
|
|
| MD5 |
3f4ff40af9deb7437d34a4b9e0889057
|
|
| BLAKE2b-256 |
8eced2c7af2155c4dc303bd2731a437263b9921aff8953641b74b4d428efd692
|