mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-27 00:01:03 -05:00
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
16 lines
289 B
Python
16 lines
289 B
Python
from fastapi import Depends, FastAPI
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
def get_username():
|
|
try:
|
|
yield "Rick"
|
|
finally:
|
|
print("Cleanup up before response is sent")
|
|
|
|
|
|
@app.get("/users/me")
|
|
def get_user_me(username: str = Depends(get_username, scope="function")):
|
|
return username
|