mirror of
https://github.com/fastapi/fastapi.git
synced 2026-04-13 19:38:34 -04:00
📝 Add tutorials python src files
This commit is contained in:
11
docs/tutorial/src/tutorial70.py
Normal file
11
docs/tutorial/src/tutorial70.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from fastapi import FastAPI, Security
|
||||
from fastapi.security import OAuth2PasswordBearer
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/token")
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(token: str = Security(oauth2_scheme)):
|
||||
return {"token": token}
|
||||
Reference in New Issue
Block a user