From 8a66588541f54d6b104fa59ea0f83d1f91e75ecd Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Sun, 21 Oct 2018 08:57:55 +0200 Subject: [PATCH] Fix error handling, add additional options in web interface --- server/daemon.py | 7 +++++-- server/hallmonitor.py | 1 + server/static/index.html | 14 +++++++++----- server/static/worker.js | 8 +++++++- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/server/daemon.py b/server/daemon.py index 7d77121..4e24b31 100644 --- a/server/daemon.py +++ b/server/daemon.py @@ -20,6 +20,7 @@ HTML = "text/html" JSON = "application/json" XML = "text/xml" TEXT = "text/plain" +PNG = "image/png" def static(req): try: @@ -92,7 +93,7 @@ def getjob(req): jobid = req.path[-1] content_disposition = None - found = glob.glob("/tmp/panosteal/%s---*" % jobid) + found = glob.glob("/tmp/panosteal/%s---.png*" % jobid) if found: md5 = "Not happening." @@ -105,12 +106,14 @@ def getjob(req): time.sleep(0.5) code = HTTP200 - ctype = mimetypes.guess_type("any.png")[0] + ctype = PNG content_disposition = found[0].split("---")[-1] + elif glob.glob("/tmp/panosteal/%s*err" % jobid): content = "

500 Internal Server Error

".encode() code = HTTP500 ctype = HTML + elif not os.path.isfile("/tmp/panosteal/%s" % jobid): content = "

404 File Not Found

".encode() code = HTTP404 diff --git a/server/hallmonitor.py b/server/hallmonitor.py index 0ba222e..3972d99 100644 --- a/server/hallmonitor.py +++ b/server/hallmonitor.py @@ -11,6 +11,7 @@ import glob processes = {} def handleIncoming(filename): + print(filename) time.sleep(1) config = configparser.ConfigParser() config.read(filename) diff --git a/server/static/index.html b/server/static/index.html index 19a295d..5863bcc 100644 --- a/server/static/index.html +++ b/server/static/index.html @@ -25,11 +25,15 @@
URL of an image contained in a krpano panorama or of a website containing a krpano panorama
-
- +
x
+
+
/ /
+
+
+
diff --git a/server/static/worker.js b/server/static/worker.js index f28b197..032bdcd 100644 --- a/server/static/worker.js +++ b/server/static/worker.js @@ -1,5 +1,11 @@ +$("#options").hide(); + $body = $("body"); +function toggleOptions() { + $("#options").toggle(); +} + function lockform() { $("#theform :input").prop("disabled", true); $body.addClass("loading"); @@ -37,7 +43,7 @@ $('#theform').submit(function(event){ }, 500: function() { clearInterval(interval); - window.alert("Failed to process request.") + window.alert("Failed to process request. The URL may be incorrect or unsupported.") unlockform(); } }