Skip to content
Discussion options

You must be logged in to vote

I think you can achieve this with a dependency:

def env(request: Request) -> Environment:
    return request.scope["env"]

Then in your route:

@app.get("/hello")
async def root(env: Environment = Depends(env), x: int = 0):
    return {"message": "Hello World", "SECRET_KEY": env.OPENAI_API_KEY}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hoodmane
Comment options

Answer selected by hoodmane
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants