aboutsummaryrefslogtreecommitdiff
path: root/hex_zero.py
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-12-18 19:11:38 -0500
committerB Stack <bgstack15@gmail.com>2020-12-18 19:25:23 -0500
commit52ac4782f7acf7994d9d9e4136fc05099d252f59 (patch)
treeb682e3f2c32f731ce34bcc4eddae9780781a99e5 /hex_zero.py
parentimprove instructions for installing short_url (diff)
downloadhex-zero-52ac4782f7acf7994d9d9e4136fc05099d252f59.tar.gz
hex-zero-52ac4782f7acf7994d9d9e4136fc05099d252f59.tar.bz2
hex-zero-52ac4782f7acf7994d9d9e4136fc05099d252f59.zip
add drag-and-drop /upload/ route
Diffstat (limited to 'hex_zero.py')
-rwxr-xr-xhex_zero.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/hex_zero.py b/hex_zero.py
index 1f3c2ab..bcd8bb3 100755
--- a/hex_zero.py
+++ b/hex_zero.py
@@ -79,9 +79,12 @@ app.config.from_pyfile("hex-zero.conf", silent=True)
dictConfig(app.config['WSGI_LOGGING'])
# read html template file
-with open(app.config["FHOST_FRONTPAGE"], "r") as j:
+with open(app.config["FRONTPAGE"], "r") as j:
frontpagestring = j.read()
+with open(app.config["DRAG_AND_DROP_PAGE"], "r") as j:
+ ddpagestring = j.read()
+
if app.config["NSFW_DETECT"]:
from nsfw_detect import NSFWDetector
nsfw = NSFWDetector()
@@ -376,6 +379,12 @@ def dump_urls(start=0):
return Response(gen(), mimetype="text/plain")
+@app.route("/upload/")
+def dd_upload():
+ return ddpagestring.format(
+ app.config["APP_PATH"]
+ )
+
@app.route("/", methods=["GET", "POST"])
def fhost():
if request.method == "POST":
@@ -415,11 +424,18 @@ def fhost():
maxsizehalf = int(maxsizehalf)
# python-interpreted variables
- return frontpagestring.format(fhost_url(),
- maxsize, str(maxsizehalf).rjust(27), str(maxsizenum).rjust(27),
- maxsizeunit.rjust(54),
- ", ".join(app.config["FHOST_MIME_BLACKLIST"]),fhost_url().split("/",2)[2],
- app.config["APP_URL"], app.config["ADMIN_EMAIL"])
+ return frontpagestring.format(
+ fhost_url(),
+ maxsize,
+ str(maxsizehalf).rjust(27),
+ str(maxsizenum).rjust(27),
+ maxsizeunit.rjust(54),
+ ", ".join(app.config["FHOST_MIME_BLACKLIST"]),
+ fhost_url().split("/",2)[2],
+ app.config["APP_URL"],
+ app.config["ADMIN_EMAIL"],
+ app.config["APP_PATH"]
+ )
@app.route("/robots.txt")
def robots():
bgstack15