Wieder was gelernt

Python Web Framework Cheat Sheet

Tags: Flask FastAPI Django Web Python Programming Reference
2022-11-01
Feature Flask FastAPI Django
Variable rules in routes <type:variable> [R]
Return HTTP error abort(code) [R]
Statt dem Code kann man auch ein Response-Objekt angeben, z.B.

abort(
    make_response(
        jsonify(message="Post not found"),
        404
    )
)

raise HTTPException(status_code=, detail=, headers=) [R] return HttpResponse(status_code=404) . For some status codes there are also predefined subclasses, so for 404, we can use return HttpResponseNotFound() or even raise Http404()