diff --git a/hub/services/static/img/sir-vala-notext.png b/hub/services/static/img/sir-vala-notext.png new file mode 100644 index 0000000..ba510c5 Binary files /dev/null and b/hub/services/static/img/sir-vala-notext.png differ diff --git a/hub/services/templates/400.html b/hub/services/templates/400.html new file mode 100644 index 0000000..1de10f9 --- /dev/null +++ b/hub/services/templates/400.html @@ -0,0 +1,20 @@ +{% extends 'services/base.html' %} +{% load static %} + +{% block title %}Bad Request (400){% endblock %} + +{% block content %} + + + + + 400 + Bad Request + Sorry, your request contains invalid syntax and cannot be fulfilled. + + Return to Homepage + + + + +{% endblock %} \ No newline at end of file diff --git a/hub/services/templates/404.html b/hub/services/templates/404.html new file mode 100644 index 0000000..023e65d --- /dev/null +++ b/hub/services/templates/404.html @@ -0,0 +1,20 @@ +{% extends 'services/base.html' %} +{% load static %} + +{% block title %}Page Not Found (404){% endblock %} + +{% block content %} + + + + + 404 + Page Not Found + Sorry, the page you are looking for does not exist or has been moved. + + Return to Homepage + + + + +{% endblock %} \ No newline at end of file diff --git a/hub/services/templates/500.html b/hub/services/templates/500.html new file mode 100644 index 0000000..c515220 --- /dev/null +++ b/hub/services/templates/500.html @@ -0,0 +1,20 @@ +{% extends 'services/base.html' %} +{% load static %} + +{% block title %}Server Error (500){% endblock %} + +{% block content %} + + + + + 500 + Server Error + Sorry, something went wrong on our server. Our team has been notified. + + Return to Homepage + + + + +{% endblock %} \ No newline at end of file diff --git a/hub/services/views/errors.py b/hub/services/views/errors.py new file mode 100644 index 0000000..6565bb6 --- /dev/null +++ b/hub/services/views/errors.py @@ -0,0 +1,16 @@ +from django.shortcuts import render + + +def bad_request(request, exception): + """400 error handler""" + return render(request, "400.html", status=400) + + +def page_not_found(request, exception): + """404 error handler""" + return render(request, "404.html", status=404) + + +def server_error(request): + """500 error handler""" + return render(request, "500.html", status=500) diff --git a/hub/urls.py b/hub/urls.py index 36261aa..e9dbf76 100644 --- a/hub/urls.py +++ b/hub/urls.py @@ -1,8 +1,16 @@ from django.conf import settings +from django.conf.urls import handler400, handler404, handler500 from django.conf.urls.static import static from django.contrib import admin +from django.shortcuts import render from django.urls import path, include +from hub.services.views.errors import bad_request, page_not_found, server_error + +handler400 = "hub.services.views.errors.bad_request" +handler404 = "hub.services.views.errors.page_not_found" +handler500 = "hub.services.views.errors.server_error" + urlpatterns = [ path("admin/", admin.site.urls), path("", include("hub.services.urls")), @@ -12,5 +20,8 @@ if settings.DEBUG: urlpatterns += [ path("__reload__/", include("django_browser_reload.urls")), path("schema-viewer/", include("schema_viewer.urls")), + path("test-400/", lambda request: render(request, "400.html"), name="test_400"), + path("test-404/", lambda request: render(request, "404.html"), name="test_404"), + path("test-500/", lambda request: render(request, "500.html"), name="test_500"), ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Sorry, your request contains invalid syntax and cannot be fulfilled.
Return to Homepage
Sorry, the page you are looking for does not exist or has been moved.
Sorry, something went wrong on our server. Our team has been notified.