From 10ea1f03cd63cdb47471f9816377eb1eac25e7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Sun, 26 Apr 2026 14:04:24 +0300 Subject: [PATCH] 403 page --- app/__init__.py | 9 +++++++++ app/templates/common/403.html | 8 ++++++++ app/templates/common/404.html | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 app/templates/common/403.html diff --git a/app/__init__.py b/app/__init__.py index cb79105..7542bd0 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -319,6 +319,15 @@ def create_app(): return {'error': 'not found'}, e.code else: return render_template('common/404.html'), e.code + + @app.errorhandler(403) + def _handle_403(e): + if request.path.startswith('/hyperapi/'): + return '

forbiddedn

', e.code + elif request.path.startswith('/api/'): + return {'error': 'forbidden'}, e.code + else: + return render_template('common/403.html'), e.code # # @app.errorhandler(413) # def _handle_413(e): diff --git a/app/templates/common/403.html b/app/templates/common/403.html new file mode 100644 index 0000000..1550ec1 --- /dev/null +++ b/app/templates/common/403.html @@ -0,0 +1,8 @@ +{%- from 'common/macros.html' import subheader -%} +{%- extends 'base.html' -%} +{%- block title -%}Forbidden{%- endblock -%} +{%- block content -%} +{%- call() subheader('403 Forbidden') -%} +You are not allowed to access this page or perform this action. +{%- endcall -%} +{%- endblock -%} diff --git a/app/templates/common/404.html b/app/templates/common/404.html index 6c4da8e..fff9448 100644 --- a/app/templates/common/404.html +++ b/app/templates/common/404.html @@ -3,6 +3,6 @@ {%- block title -%}Not found{%- endblock -%} {%- block content -%} {%- call() subheader('404 Not Found') -%} -The requested URL was not found. +The requested page was not found. {%- endcall -%} {%- endblock -%}