Skip to main content

A FastAPI utility to allow Controller Class usage

Project description

What this repository contains

A FastAPI utility to allow Controller Class usage

Installation:

install the package

pip install fastapi-router-controller

How to use

In a Class module

from fastapi import APIRouter
from fastapi_router_controller import Controller

router = APIRouter()
controller = Controller(router)

@controller.resource()
class ExampleController():
    @controller.route.get(
        '/some_aoi', 
        summary='A sample description')
    def sample_api(_):
        return 'A sample response'

Load the controller to the main FastAPI app

from fastapi import FastAPI
from fastapi_router_controller import Controller

import ExampleController

app = FastAPI(
    title='A sample application using fastapi_router_controller',
    version="0.1.0")

example_controller = ExampleController()
app.include_router(example_controller.router())

For some Example use-cases visit the example folder

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

fastapi-router-controller-0.1.0.tar.gz (3.3 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