mirror of
https://github.com/Xevion/runnerspace.git
synced 2025-12-09 04:08:31 -06:00
Create 404 catch-all page
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from flask import Flask
|
||||
from flask import Flask, render_template
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_login import LoginManager
|
||||
|
||||
@@ -31,6 +31,11 @@ def create_app():
|
||||
from .routes import blueprint as routes_blueprint
|
||||
app.register_blueprint(routes_blueprint)
|
||||
|
||||
@app.errorhandler(404)
|
||||
def page_not_found(e):
|
||||
# note that we set the 404 status explicitly
|
||||
return render_template('errors/404.html'), 404
|
||||
|
||||
# CLI commands setup
|
||||
@app.shell_context_processor
|
||||
def shell_context():
|
||||
|
||||
19
templates/errors/404.html
Normal file
19
templates/errors/404.html
Normal file
@@ -0,0 +1,19 @@
|
||||
{% extends 'layouts/index.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="content-inner" style="display: flex">
|
||||
<div style="margin: 0 auto;">
|
||||
<h2>404 - Content Not Found</h2>
|
||||
<p>
|
||||
{% if current_user.is_authenticated %}
|
||||
Sorry <strong>{{ current_user.username }}</strong>, the
|
||||
{% else %}
|
||||
The
|
||||
{% endif %} content you requested could not be found.
|
||||
<br>
|
||||
It may have been deleted or moved somewhere else.
|
||||
<span style="text-align: center">Go <a href="{{ url_for('main.index') }}">home?</a></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user