add http error codes
This commit is contained in:
parent
91c9c21fdd
commit
4146cb5b8a
1 changed files with 4 additions and 7 deletions
11
raincloud.py
11
raincloud.py
|
|
@ -7,6 +7,7 @@ import werkzeug
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from hmac import compare_digest as compare_hash
|
from hmac import compare_digest as compare_hash
|
||||||
from flask import (
|
from flask import (
|
||||||
|
abort,
|
||||||
Flask,
|
Flask,
|
||||||
render_template,
|
render_template,
|
||||||
redirect,
|
redirect,
|
||||||
|
|
@ -22,10 +23,6 @@ base_path = Path("public")
|
||||||
cloud_name = "raincloud"
|
cloud_name = "raincloud"
|
||||||
sessions = []
|
sessions = []
|
||||||
|
|
||||||
# mkpass = "$6$7lTWfEYgx.nZdM.C$jb2cQt30FzpnEibp2sN2juGL0sGT2Y9dGlVTQvqxBB579Yy5lfbt3tIHjKYnt/MIcff6I6AFp8Q5k1xjN9C8a0"
|
|
||||||
# print(compare_hash(mkpass, crypt.crypt("test", mkpass)))
|
|
||||||
# exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
class RaincloudIOException(Exception):
|
class RaincloudIOException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
@ -156,7 +153,7 @@ def directory(directory, filename=None):
|
||||||
if config["download"] and filename != "rc.toml":
|
if config["download"] and filename != "rc.toml":
|
||||||
return send_from_directory(base_path / directory, filename)
|
return send_from_directory(base_path / directory, filename)
|
||||||
else:
|
else:
|
||||||
return "Not allowed"
|
abort(403)
|
||||||
|
|
||||||
# Upload
|
# Upload
|
||||||
elif request.method == "POST":
|
elif request.method == "POST":
|
||||||
|
|
@ -169,11 +166,11 @@ def directory(directory, filename=None):
|
||||||
# Reload
|
# Reload
|
||||||
return redirect(url_for("directory", directory=directory))
|
return redirect(url_for("directory", directory=directory))
|
||||||
else:
|
else:
|
||||||
return "No upload allowed"
|
abort(403)
|
||||||
|
|
||||||
except RaincloudIOException as e:
|
except RaincloudIOException as e:
|
||||||
print(e)
|
print(e)
|
||||||
return "No 404 file"
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
app.secret_key = "raincloud"
|
app.secret_key = "raincloud"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue