decorator in FAST API (Python)
@app.get("/auth")
def authenticating():
return {"isLoggedIn": "saeed here"}
@app.get("/auth")?
This is called a decorator in Python.
A decorator is something that:
Takes a function and modifies or registers it in some way.
@app.get("/auth") means:
“Whenever someone sends a GET request to /auth, run the function written below.”
How does Python read this?
Python internally converts this:
@app.get("/auth")
def authenticating():
return {"isLoggedIn": "saeed here"}
into something like this:
def authenticating():
return {"isLoggedIn": "saeed here"}
app.get("/auth")(authenticating)
So basically:
app.get("/auth")returns a functionThat function takes
authenticatingas argumentFastAPI stores it in a routing table
So FastAPI now knows:
Route: GET /auth → Call authenticating()


