mirror of https://github.com/tiangolo/fastapi.git
12 lines
321 B
Python
12 lines
321 B
Python
from fastapi import Depends, FastAPI
|
|
from fastapi.security import HTTPBasic, HTTPBasicCredentials
|
|
|
|
app = FastAPI()
|
|
|
|
security = HTTPBasic()
|
|
|
|
|
|
@app.get("/users/me")
|
|
def read_current_user(credentials: HTTPBasicCredentials = Depends(security)):
|
|
return {"username": credentials.username, "password": credentials.password}
|