Skip to main content

A pythonic functional way to construct FastAPI applications be declaring endpoints in separation of their functional definition, enabeling to separate, replicate, and reuse functions in different APIs at the same time, and also run multiple of them.

Project description

auto-fastapi

A pythonic functional way to construct FastAPI applications be declaring endpoints in separation of their functional definition, enabeling to separate, replicate, and reuse functions in different APIs at the same time, and also run multiple of them.

Installation

pip install autl-fastapi

example

from fastapi import FastAPI

from auto_fastapi import Method, AutoFastAPI, Builder, Server, Config


def startup() -> None:
    print("startup")


def login(username: str, password: str) -> dict[str, str | dict[str, str]]:
    return {
        "response": "success",
        "request": dict(username=username, password=password)
    }


app = FastAPI()

auto = AutoFastAPI(app)
auto.push((startup, Builder.event("startup")))
auto.push((login, Builder.endpoint("/login", [Method.GET])))

server = Server(Config(app, host="127.0.0.1", port=5555))
server.run()

to stop the server

server.exit()

to run again

server.run()

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

auto-fastapi-0.0.2.tar.gz (10.5 kB view hashes)

Uploaded Source

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