From ac011a77b9472c0274e3c444aae63e6e45c3494c Mon Sep 17 00:00:00 2001 From: justcool393 Date: Tue, 11 Oct 2022 03:28:03 -0700 Subject: [PATCH] remove unneeded templates, use custom handler for 500, and 401 is "Unauthorized," not "Not Authorized" --- files/routes/errors.py | 7 ++++--- files/templates/errors/400.html | 20 -------------------- files/templates/errors/403.html | 21 --------------------- files/templates/errors/404.html | 21 --------------------- files/templates/errors/405.html | 21 --------------------- files/templates/errors/406.html | 21 --------------------- files/templates/errors/413.html | 20 -------------------- files/templates/errors/414.html | 20 -------------------- files/templates/errors/415.html | 20 -------------------- files/templates/errors/418.html | 20 -------------------- files/templates/errors/429.html | 20 -------------------- 11 files changed, 4 insertions(+), 207 deletions(-) delete mode 100644 files/templates/errors/400.html delete mode 100644 files/templates/errors/403.html delete mode 100644 files/templates/errors/404.html delete mode 100644 files/templates/errors/405.html delete mode 100644 files/templates/errors/406.html delete mode 100644 files/templates/errors/413.html delete mode 100644 files/templates/errors/414.html delete mode 100644 files/templates/errors/415.html delete mode 100644 files/templates/errors/418.html delete mode 100644 files/templates/errors/429.html diff --git a/files/routes/errors.py b/files/routes/errors.py index 6f63c2e05..0cb13116f 100644 --- a/files/routes/errors.py +++ b/files/routes/errors.py @@ -85,13 +85,13 @@ def error(e): if WERKZEUG_ERROR_DESCRIPTIONS.get(e.code, None) == details: details = None if request.headers.get("Authorization") or request.headers.get("xhr"): - return {"error": msg, "code": e.code, "details": details} + return {"error": title, "code": e.code, "description": msg, "details": details} img = ERROR_MARSEYS.get(e.code, 'marseyl') return render_template('errors/error.html', err=True, title=title, msg=msg, details=details, img=img), e.code @app.errorhandler(401) def error_401(e): - if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "401 Not Authorized"}, 401 + if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "401 Unauthorized"}, 401 else: path = request.path qs = urlencode(dict(request.values)) @@ -103,7 +103,8 @@ def error_401(e): @app.errorhandler(500) def error_500(e): g.db.rollback() - return error(e) + if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "500 Internal Server Error"}, 500 + else: return render_template('errors/500.html', err=True), 500 @app.post("/allow_nsfw") diff --git a/files/templates/errors/400.html b/files/templates/errors/400.html deleted file mode 100644 index 894d59c7a..000000000 --- a/files/templates/errors/400.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "default.html" %} - -{% block title %} -400 Bad Request -{% endblock %} - -{% block pagetype %}error-400{% endblock %} - -{% block content %} -
-
-
- :#marseybrainlet: -

-			

400 Bad Request

-

That request was bad and you should feel bad.

-
-
-
-{% endblock %} diff --git a/files/templates/errors/403.html b/files/templates/errors/403.html deleted file mode 100644 index ae6535659..000000000 --- a/files/templates/errors/403.html +++ /dev/null @@ -1,21 +0,0 @@ -{% extends "default.html" %} - -{% block title %} -403 Forbidden -{% endblock %} - -{% block pagetype %}error-403{% endblock %} - -{% block content %} -
-
-
- :#marseytroll: -

-		

403 Forbidden

-

{{description}}

-
Go to frontpage
-
-
-
-{% endblock %} diff --git a/files/templates/errors/404.html b/files/templates/errors/404.html deleted file mode 100644 index a5b7ce074..000000000 --- a/files/templates/errors/404.html +++ /dev/null @@ -1,21 +0,0 @@ -{% extends "default.html" %} - -{% block title %} -404 Page Not Found -{% endblock %} - -{% block pagetype %}error-404{% endblock %} - -{% block content %} -
-
-
- :#marseyconfused -

-		

404 Page Not Found

-

Someone typed something wrong and it was probably you, please do better.

-
Go to frontpage
-
-
-
-{% endblock %} diff --git a/files/templates/errors/405.html b/files/templates/errors/405.html deleted file mode 100644 index 33215384a..000000000 --- a/files/templates/errors/405.html +++ /dev/null @@ -1,21 +0,0 @@ -{% extends "default.html" %} - -{% block title %} -405 Method Not Allowed -{% endblock %} - -{% block pagetype %}error-405{% endblock %} - -{% block content %} -
-
-
- :#marseyretard: -

-		

405 Method Not Allowed

-

idk how anyone gets this error but if you see this, remember to follow @carpathianflorist
the original error text here talked about internet gremlins and wtf

-
Go to frontpage
-
-
-
-{% endblock %} diff --git a/files/templates/errors/406.html b/files/templates/errors/406.html deleted file mode 100644 index 2b36f518c..000000000 --- a/files/templates/errors/406.html +++ /dev/null @@ -1,21 +0,0 @@ -{% extends "default.html" %} - -{% block title %} -Too many pings -{% endblock %} - -{% block pagetype %}Too many pings{% endblock %} - -{% block content %} -
-
-
- :#marseyrage -

-		

Too many pings

-

Max limit is 5 for comments and 50 for posts

-
Go to frontpage
-
-
-
-{% endblock %} diff --git a/files/templates/errors/413.html b/files/templates/errors/413.html deleted file mode 100644 index 3dae7f9b8..000000000 --- a/files/templates/errors/413.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "default.html" %} - -{% block title %} -Max image/audio size is 8 MB (16 MB for paypigs) -{% endblock %} - -{% block pagetype %}error-413{% endblock %} - -{% block content %} -
-
-
- :#marseyretard: -

-		

Max image/audio size is 8 MB (16 MB for paypigs)

-
Go to frontpage
-
-
-
-{% endblock %} diff --git a/files/templates/errors/414.html b/files/templates/errors/414.html deleted file mode 100644 index e054bf531..000000000 --- a/files/templates/errors/414.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "default.html" %} - -{% block title %} -Max video size is 32 MB (64 MB for paypigs) -{% endblock %} - -{% block pagetype %}error-414{% endblock %} - -{% block content %} -
-
-
- :#marseyretard: -

-		

Max video size is 32 MB (64 MB for paypigs)

-
Go to frontpage
-
-
-
-{% endblock %} diff --git a/files/templates/errors/415.html b/files/templates/errors/415.html deleted file mode 100644 index 0139fd86d..000000000 --- a/files/templates/errors/415.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "default.html" %} - -{% block title %} -415 Unsupported Media Type -{% endblock %} - -{% block pagetype %}error-415{% endblock %} - -{% block content %} -
-
-
- :#marseydetective: -

-		

415 Unsupported Media Type

-

Please upload only Image, Video, or Audio files!

-
-
-
-{% endblock %} diff --git a/files/templates/errors/418.html b/files/templates/errors/418.html deleted file mode 100644 index 15642a384..000000000 --- a/files/templates/errors/418.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "default.html" %} - -{% block title %} -WEBM videos are not allowed -{% endblock %} - -{% block pagetype %}error-418{% endblock %} - -{% block content %} -
-
-
- :#marseytea: -

-		

WEBM videos are not allowed

-
Please convert your video to MP4 and re-upload it!
-
-
-
-{% endblock %} \ No newline at end of file diff --git a/files/templates/errors/429.html b/files/templates/errors/429.html deleted file mode 100644 index 0860ae1f2..000000000 --- a/files/templates/errors/429.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "default.html" %} - -{% block title %} -429 Too Many Requests -{% endblock %} - -{% block pagetype %}error-429{% endblock %} - -{% block content %} -
-
-
- :#marseyrentfree: -

-		

429 Too Many Requests

-

go spam somewhere else nerd

-
-
-
-{% endblock %}