Status Code in FastAPI
noun
say it: “STAT-us KOHD in FAST-AY-PEE-EYE” /ˈstætəs ˈkoʊd ɪn ˈfæstˌeɪˌpiˌaɪ/
The number a FastAPI route answers with when it succeeds, set with status_code= on its decorator, such as 201 for a newly created item.
What is Status Code in FastAPI?
Set an endpoint's success status code with status_code=, such as 201 for created.
@app.post('/reviews', status_code=201)
def add_review(review: ReviewIn):
return save_review(review)
In a sentence
- “The bakery's POST route sets its status code to 201, since it creates a special.”
- “Without status_code=201, FastAPI answers every success with the status code 200.”
Level: Apprentice · More FastAPI terms at this level
Updated