Flask 3 · Routes and requests
Return JSON
Return a dict or list and Flask converts it to JSON, with a status code.
@app.post("/api/users")
def create_user():
return {"id": 1, "name": "Ada"}, 201
Official Flask 3 documentation
Flask 3 · Routes and requests
Return a dict or list and Flask converts it to JSON, with a status code.
@app.post("/api/users")
def create_user():
return {"id": 1, "name": "Ada"}, 201
Official Flask 3 documentation
Was this page helpful?