Skip to content
Snippets Groups Projects
Commit 0124b35b authored by Ethan Clay's avatar Ethan Clay
Browse files

Add favicon, add exceptions to 404 error being thrown if it is for images or the ico

parent dd2495ed
No related branches found
No related tags found
No related merge requests found
from flask import Flask, g, abort, request, session, redirect, url_for
from flask import Flask, g, abort, request, session, redirect, url_for, current_app
from config import Config
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
......@@ -158,6 +158,18 @@ def create_app(config_class=Config):
response.headers['X-Frame-Options'] = 'SAMEORIGIN'
return response
@app.errorhandler(404)
def handle_exception(e):
# Create tuple of ignored url endings. Can add other whitelisted files, perhaps .js?
allowed_extensions = tuple(current_app.config['ALLOWED_EXTENSIONS'] | {'ico'})
if any(request.path.endswith(ext) for ext in allowed_extensions):
return "", 404
else:
app.logger.error(f"Page not found: {request.path}")
session['error_message'] = f"Page not found: {request.path}"
return redirect(url_for('errors.error'))
@app.errorhandler(Exception)
def handle_exception(e):
......
app/favicon.ico

158 KiB

app/static/favicon.ico

13.6 KiB

......@@ -44,6 +44,7 @@
<script src="{{ url_for('static', filename='generic.js') }}"></script>
<title>Horizon Travels</title>
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon">
</head>
<body>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment