Skip to content

Commit 6b5b43e

Browse files
committed
Merge branch 'main' of https://github.com/sandromatter/PROG2 into main
2 parents 49cce7e + 3ceab04 commit 6b5b43e

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# .env
22
# Environment variables
3-
# Secret Key is just for testing purposes. Create a new secret key on your live server env!
3+
# Secret key is just for dev env. Create a new secret key on your live env.
4+
45

56
SECRET_KEY = '\x83\xe2\\\xf5\xbb\xa5\xb5,\x8a\xcd\xfds^\xe34\x9c'

app.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ def index():
6969
return render_template(page_path_index, title="Pyfeed", description="The modern 2020 python feedburner.")
7070

7171

72+
# Custom error page for 404
73+
@app.errorhandler(404)
74+
def page_not_found(error):
75+
return render_template("/pages/404.html"), 404
76+
77+
78+
# Custom error page for 500
79+
@app.errorhandler(500)
80+
def internal_error(error):
81+
return render_template("/pages/500.html"),500
82+
83+
7284
# Introduction page
7385
@app.route("/introduction")
7486
def introduction():

frontend/pages/404.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% extends "/templates/main.html" %}
2+
3+
{% block content %}
4+
5+
<div class="row h-100 align-items-center text-center">
6+
7+
<!-- Content here -->
8+
<div class="col-12">
9+
<h1 class="display-1 text-responsive mb-3">Error 404: Page not found 🧐</h1>
10+
<p class="lead mb-4">Uh oh! Something seems to have malfunctioned. It looks like you have called a URL that does not exist.</p>
11+
<button type="button" class="btn btn-primary btn-lg mb-2 mx-1" onclick="window.location.href='{{ url_for( 'index') }}';">Take me to the home page</button>
12+
</div>
13+
14+
</div>
15+
16+
{% endblock %}

frontend/pages/500.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% extends "/templates/main.html" %}
2+
3+
{% block content %}
4+
5+
<div class="row h-100 align-items-center text-center">
6+
7+
<!-- Content here -->
8+
<div class="col-12">
9+
<h1 class="display-1 text-responsive mb-3">Error 500: Internal server error 🤯</h1>
10+
<p class="lead mb-4">Uh oh! An error occurred while connecting to the server. The requested page cannot be accessed.</p>
11+
<button type="button" class="btn btn-primary btn-lg mb-2 mx-1" onclick="window.location.href='{{ url_for( 'index') }}';">Take me to the home page</button>
12+
</div>
13+
14+
</div>
15+
16+
{% endblock %}

0 commit comments

Comments
 (0)