Untitled

 avatar
user_2399404
plain_text
25 days ago
384 B
141
Indexable
Dependency Injection code

def get_current_user(authorization:str= Header(...)):
    if authorization != "valid-token":
         raise HTTPException(status_code = 401, detail="invalid token aman sir ji")
    return {"user_id":1, "name":"aman"}
    
@app.get("/cart")
def get_cart(user :dict = Depends(get_current_user)):

    return {"cart":"Aman items", "user_name":user["name"]}



Editor is loading...
Leave a Comment