-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Closed
Labels
Description
I would like to access the FastAPI app in a Depends function, is there a way to do that?
The rationale here is that I would like to avoid global variables and use the state in app.
Example usecase:
def get_session(app: fastapi.FastAPI) -> Session:
[...]
access the app.state here
[...]
@router.post("/init")
def create(session: Session = Depends(get_session)):
[...]
use the SQLAlchemy session
[...]
Reactions are currently unavailable