30 lines
665 B
Python
30 lines
665 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.responses import StreamingResponse
|
|
from fastapi.encoders import jsonable_encoder
|
|
|
|
from . import tools
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
origins = [
|
|
"http://localhost.tiangolo.com",
|
|
"https://localhost.tiangolo.com",
|
|
"http://localhost",
|
|
"http://localhost:8080",
|
|
]
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
for tool in tools.get_tools():
|
|
component, method = tool.__name__.split('.')
|
|
path = f'/{component}/{method}'
|
|
app.get(path, response_model=None)(tool)
|