mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-24 08:16:11 -04:00
📝 Update source examples and docs from Python 3.9 to 3.10 (#14900)
This commit is contained in:
committed by
GitHub
parent
d06ab3f5c7
commit
c9e2277d8b
15
docs_src/dependencies/tutorial008e_py310.py
Normal file
15
docs_src/dependencies/tutorial008e_py310.py
Normal file
@@ -0,0 +1,15 @@
|
||||
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
|
||||
Reference in New Issue
Block a user