Fix error handling, add additional options in web interface
This commit is contained in:
parent
e070665f3d
commit
8a66588541
4 changed files with 22 additions and 8 deletions
|
@ -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 = "<h1>500 Internal Server Error</h1>".encode()
|
||||
code = HTTP500
|
||||
ctype = HTML
|
||||
|
||||
elif not os.path.isfile("/tmp/panosteal/%s" % jobid):
|
||||
content = "<h1>404 File Not Found</h1>".encode()
|
||||
code = HTTP404
|
||||
|
|
|
@ -11,6 +11,7 @@ import glob
|
|||
processes = {}
|
||||
|
||||
def handleIncoming(filename):
|
||||
print(filename)
|
||||
time.sleep(1)
|
||||
config = configparser.ConfigParser()
|
||||
config.read(filename)
|
||||
|
|
|
@ -25,11 +25,15 @@
|
|||
<form class="" id="theform">
|
||||
<div class="form-group"> <label>URL</label> <input type="text" class="form-control" placeholder="https://example.com/0/0/0_0.jpg" name="url" required="required"> <small class="form-text text-muted">URL of an image contained in a krpano panorama or of a website containing a krpano panorama</small> </div>
|
||||
<div class="form-group"> <label>Title</label> <input type="" class="form-control" placeholder="1234 - Shiny Place" name="title"> </div>
|
||||
<div class="form-group"> <label style="display: block;">Resolution</label> <input type="" class="form-control" placeholder="3840" name="width" style="width: 100px; display: inline;"> x <input type="" class="form-control" placeholder="1920" name="width" style="width: 100px; display: inline;"> </div>
|
||||
<div id="options">
|
||||
<div class="form-group"> <label style="display: block;">Rotation on X/Y/Z axes</label> <input type="" class="form-control" placeholder="0" name="rx" style="width: 100px; display: inline;"> / <input type="" class="form-control" placeholder="0" name="ry" style="width: 100px; display: inline;"> / <input type="" class="form-control" placeholder="0" name="rz" style="width: 100px; display: inline;"> </div>
|
||||
<div class="form-group"> <label>Transposition<br></label><select class="custom-control custom-select" name="transpose">
|
||||
<option value="1" selected="True">Default: Flip left-right (mirror)</option>
|
||||
<option value="0">No transposition</option>
|
||||
</select> </div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">Submit</button> <button type="reset" class="btn btn-danger">Reset</button> <button class="btn btn-info" onclick="toggleOptions()">More options</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue