403 page
This commit is contained in:
@@ -319,6 +319,15 @@ def create_app():
|
|||||||
return {'error': 'not found'}, e.code
|
return {'error': 'not found'}, e.code
|
||||||
else:
|
else:
|
||||||
return render_template('common/404.html'), e.code
|
return render_template('common/404.html'), e.code
|
||||||
|
|
||||||
|
@app.errorhandler(403)
|
||||||
|
def _handle_403(e):
|
||||||
|
if request.path.startswith('/hyperapi/'):
|
||||||
|
return '<h1>forbiddedn</h1>', e.code
|
||||||
|
elif request.path.startswith('/api/'):
|
||||||
|
return {'error': 'forbidden'}, e.code
|
||||||
|
else:
|
||||||
|
return render_template('common/403.html'), e.code
|
||||||
#
|
#
|
||||||
# @app.errorhandler(413)
|
# @app.errorhandler(413)
|
||||||
# def _handle_413(e):
|
# def _handle_413(e):
|
||||||
|
|||||||
8
app/templates/common/403.html
Normal file
8
app/templates/common/403.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{%- from 'common/macros.html' import subheader -%}
|
||||||
|
{%- extends 'base.html' -%}
|
||||||
|
{%- block title -%}Forbidden{%- endblock -%}
|
||||||
|
{%- block content -%}
|
||||||
|
{%- call() subheader('403 Forbidden') -%}
|
||||||
|
<span>You are not allowed to access this page or perform this action.</span>
|
||||||
|
{%- endcall -%}
|
||||||
|
{%- endblock -%}
|
||||||
@@ -3,6 +3,6 @@
|
|||||||
{%- block title -%}Not found{%- endblock -%}
|
{%- block title -%}Not found{%- endblock -%}
|
||||||
{%- block content -%}
|
{%- block content -%}
|
||||||
{%- call() subheader('404 Not Found') -%}
|
{%- call() subheader('404 Not Found') -%}
|
||||||
<span>The requested URL was not found.</span>
|
<span>The requested page was not found.</span>
|
||||||
{%- endcall -%}
|
{%- endcall -%}
|
||||||
{%- endblock -%}
|
{%- endblock -%}
|
||||||
|
|||||||
Reference in New Issue
Block a user