diff --git a/fedireads/templates/error.html b/fedireads/templates/error.html new file mode 100644 index 000000000..d3e514013 --- /dev/null +++ b/fedireads/templates/error.html @@ -0,0 +1,10 @@ +{% extends 'layout.html' %} +{% block content %} + +
+

Server Error

+

Something went wrong! Sorry about that.

+
+ +{% endblock %} + diff --git a/fedireads/templates/notfound.html b/fedireads/templates/notfound.html new file mode 100644 index 000000000..6c9f1b10d --- /dev/null +++ b/fedireads/templates/notfound.html @@ -0,0 +1,9 @@ +{% extends 'layout.html' %} +{% block content %} + +
+

Not Found

+

The page your requested doesn't seem to exist!

+
+ +{% endblock %} diff --git a/fedireads/urls.py b/fedireads/urls.py index c869d3c1b..aa9ba3625 100644 --- a/fedireads/urls.py +++ b/fedireads/urls.py @@ -13,6 +13,8 @@ local_user_path = r'^user/%s' % localname_regex status_path = r'%s/(status|review|comment)/(?P\d+)' % local_user_path book_path = r'^book/(?P[\w\-]+)' +handler404 = 'fedireads.views.not_found_page' +handler500 = 'fedireads.views.server_error_page' urlpatterns = [ path('admin/', admin.site.urls), diff --git a/fedireads/views.py b/fedireads/views.py index 0f3f2b691..0d900afd2 100644 --- a/fedireads/views.py +++ b/fedireads/views.py @@ -25,6 +25,16 @@ def is_api_request(request): request.path[-5:] == '.json' +def server_error_page(request): + ''' 500 errors ''' + return TemplateResponse(request, 'error.html') + + +def not_found_page(request, _): + ''' 404s ''' + return TemplateResponse(request, 'notfound.html') + + @login_required def home(request): ''' this is the same as the feed on the home tab '''