Coverage for docs_src / security / tutorial006_an_py310.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-04-06 01:24 +0000

1from typing import Annotated 1abcdefgh

2 

3from fastapi import Depends, FastAPI 1abcdefgh

4from fastapi.security import HTTPBasic, HTTPBasicCredentials 1abcdefgh

5 

6app = FastAPI() 1abcdefgh

7 

8security = HTTPBasic() 1abcdefgh

9 

10 

11@app.get("/users/me") 1abcdefgh

12def read_current_user(credentials: Annotated[HTTPBasicCredentials, Depends(security)]): 1abcdefgh

13 return {"username": credentials.username, "password": credentials.password} 1ijkl