Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Flask
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ethan2.Clay@live.uwe.ac.uk
Flask
Commits
0124b35b
Commit
0124b35b
authored
3 months ago
by
Ethan Clay
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/__init__.py
+13
-1
13 additions, 1 deletion
app/__init__.py
app/favicon.ico
+0
-0
0 additions, 0 deletions
app/favicon.ico
app/static/favicon.ico
+0
-0
0 additions, 0 deletions
app/static/favicon.ico
app/templates/base.html
+1
-0
1 addition, 0 deletions
app/templates/base.html
with
14 additions
and
1 deletion
app/__init__.py
+
13
−
1
View file @
0124b35b
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
):
...
...
This diff is collapsed.
Click to expand it.
app/favicon.ico
deleted
100644 → 0
+
0
−
0
View file @
dd2495ed
158 KiB
This diff is collapsed.
Click to expand it.
app/static/favicon.ico
0 → 100644
+
0
−
0
View file @
0124b35b
13.6 KiB
This diff is collapsed.
Click to expand it.
app/templates/base.html
+
1
−
0
View file @
0124b35b
...
...
@@ -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>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment