Fastapi integration for rewire
Project description
rewire_fastapi
A FastAPI integration for rewire.
Installation
To get started, install rewire_fastapi using pip:
pip install rewire_fastapi
Supported Servers
This package supports running with both Uvicorn and Hypercorn servers (rewire_fastapi.server).
Usage
First, import add rewire_fastapi to your rewire application:
# ...
import rewire_fastapi
async def main():
async with Space().init().use():
DependenciesModule.get().add(rewire_fastapi.plugin) # add this
# ...
Then have injected fastapi in your files:
from fastapi import APIRouter, FastAPI
from rewire.plugins import simple_plugin
plugin = simple_plugin()
router = APIRouter()
@router.get("/hello")
def hello_world():
return "world"
@plugin.setup()
async def include_router(app: FastAPI):
app.include_router(router)
Configuration
Configure the package in config.yaml file:
rewire_fastapi:
server: "hypercorn"
app: # will be passed to FastAPI instance
title: "My App"
uvicorn: # (optional)
port: 1234
hypercorn: # (optional)
bind: "0.0.0.0:1234"
routes: # (optional)
tag_prefix: "myapp:"
patch: # (optional)
swagger_hierarchical_tags: true
tag_prefixes: true
middleware:
cors: # enable cors middleware (optional)
allow_origins: ["*"]
allow_methods: ["*"]
allow_headers: ["*"]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rewire_fastapi-0.2.0.tar.gz
(6.3 kB
view hashes)
Built Distribution
Close
Hashes for rewire_fastapi-0.2.0-py3-none-any.whl
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | c6c7cd18dcd60bcf4938b341dd93beee92b0e8b976a07aea1f54329cbfbfa19b |
|
| MD5 | 5616cec37c0722233701ba8d5e5d9f26 |
|
| BLAKE2b-256 | b3e288b198858f9487cbe816767a2ffe5b3417e48cf28710848bd528d50069ee |