-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Currently, the server is a function that wraps up building a FastAPI instance and serving it using uvicorn.run().
But for operational use, we don't need to serve it, because the user can serve the app (for example in a dockerfile uvicorn cli command with worker settings etc)
The user might also need to add to the FastAPI instance before serving, for example adding HTTP headers, custom logs and authentication middleware.
Proposal
The server module builds the FastAPI object and returns it so that the user can run something like:
from server import ClassifAIServer
server = ClassifAIServer(...
)
app = server.expose_app()
# The app is a FastAPI object
# You can then do uvicorn main:app
# Example, adding HTTP headers
@app.middleware("http")
def add_headers(...):
pass
# Alternatively to call the python script directly
# Works same as start_api()
server.run()Maybe it would be possible to subclass FastAPI then add .run() as a method directly. But maybe this is easier
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels