Spaces:
Runtime error
Runtime error
Commit ·
7381953
1
Parent(s): 7585217
update
Browse files
project/__init__.py
CHANGED
|
@@ -31,9 +31,11 @@ def create_app(config_class=Config):
|
|
| 31 |
from project.users.routes import users
|
| 32 |
from project.posts.routes import posts
|
| 33 |
from project.main.routes import main
|
|
|
|
| 34 |
|
| 35 |
app.register_blueprint(users)
|
| 36 |
app.register_blueprint(posts)
|
| 37 |
app.register_blueprint(main)
|
|
|
|
| 38 |
|
| 39 |
return app
|
|
|
|
| 31 |
from project.users.routes import users
|
| 32 |
from project.posts.routes import posts
|
| 33 |
from project.main.routes import main
|
| 34 |
+
from project.errors.handles import error
|
| 35 |
|
| 36 |
app.register_blueprint(users)
|
| 37 |
app.register_blueprint(posts)
|
| 38 |
app.register_blueprint(main)
|
| 39 |
+
app.register_blueprint(error)
|
| 40 |
|
| 41 |
return app
|
project/errors/__init__.py
ADDED
|
File without changes
|
project/errors/handles.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Blueprint,render_template
|
| 2 |
+
|
| 3 |
+
error= Blueprint('errors',"__name__")
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
@error.app_error_handler(404)
|
| 8 |
+
def error_404(error):
|
| 9 |
+
return render_template('errors/404.html'), 404
|
| 10 |
+
|
| 11 |
+
@error.app_error_handler(403)
|
| 12 |
+
def error_403(error):
|
| 13 |
+
return render_template('errors/403.html'), 403
|
| 14 |
+
|
| 15 |
+
@error.app_error_handler(500)
|
| 16 |
+
def error_500(error):
|
| 17 |
+
return render_template('errors/500.html'), 500
|
| 18 |
+
|
project/templates/errors/403.html
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%extends "layout.html" %}
|
| 2 |
+
{% block content%}
|
| 3 |
+
<div class='content-section'>
|
| 4 |
+
<h1>You dont have permission to do that. (403)</h1>
|
| 5 |
+
<p>Please check your account and try again.</p>
|
| 6 |
+
</div>
|
| 7 |
+
{% endblock content%}
|
project/templates/errors/404.html
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%extends "layout.html" %}
|
| 2 |
+
{% block content%}
|
| 3 |
+
<div class='content-section'>
|
| 4 |
+
<h1>Oops page not found. (404)</h1>
|
| 5 |
+
<p>That page does not exist. Please try a different location</p>
|
| 6 |
+
</div>
|
| 7 |
+
{% endblock content%}
|
project/templates/errors/500.html
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%extends "layout.html" %}
|
| 2 |
+
{% block content%}
|
| 3 |
+
<div class='content-section'>
|
| 4 |
+
<h1>Something went wrong. (500)</h1>
|
| 5 |
+
<p>We're experiencing some trouble on our end. Please try agian in the near future.</p>
|
| 6 |
+
</div>
|
| 7 |
+
{% endblock content%}
|