Skip to main content

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.json generation mechanism;
  • A way to provide Swagger and/or Redoc;
  • Write unit tests.

Metadata

Release files for flask-api-factory 0.2.3

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-api-factory 0.2.3
File Size Uploaded
flask_api_factory-0.2.3.tar.gz 8.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flask-api-factory 0.2.3
File Interpreter ABI Platform
flask_api_factory-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 19.7 kB

Release files / flask_api_factory-0.2.3.tar.gz

Download URL flask_api_factory-0.2.3.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d94017a5e388c1f9220951b5991ec2a5c1c8894566afda0484401f338df07285
BLAKE2b-256 checksum
How to use checksums
b0a85dd9cb8d2559960d7899ffafbd05ff166a84bafe42b776458b5181094f21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.10.10 Linux/5.15.0-1033-azure

Release files / flask_api_factory-0.2.3-py3-none-any.whl

Download URL flask_api_factory-0.2.3-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0f6a1e811fd07ed1625264f6b9923b63d4798118fa8c970eee2691f83c84c8de
BLAKE2b-256 checksum
How to use checksums
8eced2c7af2155c4dc303bd2731a437263b9921aff8953641b74b4d428efd692
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.10.10 Linux/5.15.0-1033-azure

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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