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.1.3.tar.gz (10.5 kB view details)

Uploaded Source

File details

Details for the file auto-fastapi-0.1.3.tar.gz.

File metadata

  • Download URL: auto-fastapi-0.1.3.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for auto-fastapi-0.1.3.tar.gz
Algorithm Hash digest
SHA256 bc4eb85826a42448ead733bd39bccffc220234f35172a8ccb1619cc552642424
MD5 4d4cb4a6ccc87ec7f2bf60aeaabcff49
BLAKE2b-256 d64187078daeaf784c8d954806c6f1b3ca47036aca2d87e029f30c4722d8f13a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page