Better error pages
This commit is contained in:
parent
c33060f27e
commit
be2409fc68
11
run.py
11
run.py
|
@ -57,6 +57,10 @@ def auth(key):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def error_page(error):
|
||||||
|
return render_template('error.html', page=config["SITE_DATA"], error=error)
|
||||||
|
|
||||||
|
|
||||||
def allowed_file(filename):
|
def allowed_file(filename):
|
||||||
if config["ALLOW_ALL_FILES"]:
|
if config["ALLOW_ALL_FILES"]:
|
||||||
return True
|
return True
|
||||||
|
@ -96,7 +100,7 @@ def upload_file():
|
||||||
return json.dumps(data)
|
return json.dumps(data)
|
||||||
else:
|
else:
|
||||||
print_log('Notice', 'Forbidden file received')
|
print_log('Notice', 'Forbidden file received')
|
||||||
return render_template('error.html', page=config["SITE_DATA"], error="This file isn't allowed, sorry!")
|
return error_page("This file isn't allowed, sorry!")
|
||||||
|
|
||||||
# Return Web UI if we have a GET request
|
# Return Web UI if we have a GET request
|
||||||
elif request.method == 'GET':
|
elif request.method == 'GET':
|
||||||
|
@ -116,6 +120,11 @@ def privacy():
|
||||||
def faq():
|
def faq():
|
||||||
return render_template('faq.html', page=config["SITE_DATA"])
|
return render_template('faq.html', page=config["SITE_DATA"])
|
||||||
|
|
||||||
|
# Custom 404
|
||||||
|
@app.errorhandler(404)
|
||||||
|
def page_not_found(e):
|
||||||
|
return render_template('error.html', page=config["SITE_DATA"], error="We couldn't find that. Are you sure you know what you're looking for?"), 404
|
||||||
|
|
||||||
|
|
||||||
@app.route('/<filename>', methods=['GET'])
|
@app.route('/<filename>', methods=['GET'])
|
||||||
def get_file(filename):
|
def get_file(filename):
|
||||||
|
|
Loading…
Reference in New Issue