From c74feda222745ab7cca8993df83d9ea5f9d07e5b Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Sat, 14 Nov 2026 19:43:28 +0100 Subject: refactor(core): use HTTPStatus consistently Replace numeric HTTP response and assertion codes in views and tests with `HTTPStatus` members so status handling is more descriptive and consistent. --- webmentions_ssg/views/endpoint.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'webmentions_ssg/views/endpoint.py') diff --git a/webmentions_ssg/views/endpoint.py b/webmentions_ssg/views/endpoint.py index 85ec398..06740e5 100644 --- a/webmentions_ssg/views/endpoint.py +++ b/webmentions_ssg/views/endpoint.py @@ -6,6 +6,7 @@ import uuid from datetime import UTC, datetime, timedelta +from http import HTTPStatus from typing import cast import sqlalchemy as sa @@ -141,7 +142,7 @@ def endpoint() -> ResponseReturnValue: form = forms.EndpointForm(meta={"csrf": False}) if not form.validate_on_submit(): - return form.errors, 400 + return form.errors, HTTPStatus.BAD_REQUEST source = cast(str, form.source.data) target = cast(str, form.target.data) @@ -149,7 +150,7 @@ def endpoint() -> ResponseReturnValue: result = submit_received(source, target) if result is None: - return {"error": "Webmention URL fingerprint conflict"}, 409 + return {"error": "Webmention URL fingerprint conflict"}, HTTPStatus.CONFLICT identifier, should_verify = result @@ -158,7 +159,7 @@ def endpoint() -> ResponseReturnValue: status_url = url_for("root.status", identifier=str(identifier), _external=True) - return Response(status=201, headers={"Location": status_url}) + return Response(status=HTTPStatus.CREATED, headers={"Location": status_url}) @root_page.route("/status/") -- cgit v1.3.1