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.1.1.tar.gz
(5.5 kB
view details)
Built Distribution
File details
Details for the file rewire_fastapi-0.1.1.tar.gz
.
File metadata
- Download URL: rewire_fastapi-0.1.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bc5087698fe581702777325fbe8655a505f156a3d8a5971e661bc47d21a48a1 |
|
MD5 | 67e6d04a7455656f9bab77155990e728 |
|
BLAKE2b-256 | 6d44d60276d2b7dc7a25a5b900972743bf2aa53db6c23d86c8b692b1aa54ec75 |
File details
Details for the file rewire_fastapi-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: rewire_fastapi-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac865984b64cd5bd808ffd283a952d9f71ccee161f94d402670325eb728578e0 |
|
MD5 | 0162895f9847d432e4aad34e81da14b4 |
|
BLAKE2b-256 | b255378b8d59ca7f55d92831772a5b0812076f51047b163d7d1821dca7e18a3c |