bb
This commit is contained in:
parent
c0f3d5cb68
commit
d1edad9965
49 changed files with 117 additions and 118 deletions
|
@ -7,7 +7,7 @@ from files.__main__ import app, limiter
|
|||
|
||||
@app.errorhandler(400)
|
||||
def error_400(e):
|
||||
if request.headers.get("Authorization"): return {"error": "400 Bad Request"}, 400
|
||||
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "400 Bad Request"}, 400
|
||||
else: return render_template('errors/400.html', err=True), 400
|
||||
|
||||
@app.errorhandler(401)
|
||||
|
@ -18,25 +18,25 @@ def error_401(e):
|
|||
argval = quote(f"{path}?{qs}", safe='')
|
||||
output = f"/login?redirect={argval}"
|
||||
|
||||
if request.headers.get("Authorization"): return {"error": "401 Not Authorized"}, 401
|
||||
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "401 Not Authorized"}, 401
|
||||
else: return redirect(output)
|
||||
|
||||
|
||||
@app.errorhandler(403)
|
||||
def error_403(e):
|
||||
if request.headers.get("Authorization"): return {"error": "403 Forbidden"}, 403
|
||||
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "403 Forbidden"}, 403
|
||||
else: return render_template('errors/403.html', err=True), 403
|
||||
|
||||
|
||||
@app.errorhandler(404)
|
||||
def error_404(e):
|
||||
if request.headers.get("Authorization"): return {"error": "404 Not Found"}, 404
|
||||
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "404 Not Found"}, 404
|
||||
else: return render_template('errors/404.html', err=True), 404
|
||||
|
||||
|
||||
@app.errorhandler(405)
|
||||
def error_405(e):
|
||||
if request.headers.get("Authorization"): return {"error": "405 Method Not Allowed"}, 405
|
||||
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "405 Method Not Allowed"}, 405
|
||||
else: return render_template('errors/405.html', err=True), 405
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ def error_413(e):
|
|||
|
||||
@app.errorhandler(429)
|
||||
def error_429(e):
|
||||
if request.headers.get("Authorization"): return {"error": "429 Too Many Requests"}, 429
|
||||
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "429 Too Many Requests"}, 429
|
||||
else: return render_template('errors/429.html', err=True), 429
|
||||
|
||||
|
||||
|
@ -54,7 +54,7 @@ def error_429(e):
|
|||
def error_500(e):
|
||||
g.db.rollback()
|
||||
|
||||
if request.headers.get("Authorization"): return {"error": "500 Internal Server Error"}, 500
|
||||
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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue