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: ["*"]
Release files for rewire-fastapi 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rewire_fastapi-0.2.0.tar.gz | 6.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rewire_fastapi-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.9 kB
Release files / rewire_fastapi-0.2.0.tar.gz
| Download URL | rewire_fastapi-0.2.0.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b338d9e35318d788f1fb62a89b71742c116041a2b2247e7c49d228817bc5c60
|
|
BLAKE2b-256 checksum How to use checksums |
cd08b51a0bf5334eb7de04c4b182a9bd74c559cd52da9bca47c7b2a11136f871
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / rewire_fastapi-0.2.0-py3-none-any.whl
| Download URL | rewire_fastapi-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c6c7cd18dcd60bcf4938b341dd93beee92b0e8b976a07aea1f54329cbfbfa19b
|
|
BLAKE2b-256 checksum How to use checksums |
b3e288b198858f9487cbe816767a2ffe5b3417e48cf28710848bd528d50069ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|