mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-29 01:00:51 -05:00
Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com> Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
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}
|