#!/usr/bin/python from bottle import route, run, static_file, request import makeDither import urlDownload from os import urandom from uuid import uuid4 from pbutils import now, hexdir, pb_s3 nametag = "imDither"; @route('/') def server_static(): return static_file("imdither.html", root='./') #@route('/getId') #def make_id(): # return "%s_%s_%s" % (uuid4(), nametag, now()); @route('/dithers/') def server_static(filename): return static_file(filename, root='./dithers/') @route('/img/') def server_static(filename): return static_file(filename, root='./img/') @route('/') def server_static(filename): return static_file(filename, root='./') @route('/process', method='POST') def process_image(): url = request.forms.get('url') params = request.forms.get('params') unique_id = request.forms.get('unique_id'); download = urlDownload.UrlDownload(url) tempfile = download.dir + download.filename dither = makeDither.Dither(tempfile) hexdir_name = hexdir(dither.result_file); return pb_s3(hexdir_name, dither.result_file); @route('/status', method='GET') def show_status(): pass run(host='localhost', port=4111, debug=True) #run(server='flup', host='localhost', port=4111, debug=True)