summaryrefslogtreecommitdiff
path: root/impattern/run.py
blob: 71cc247de6afa934f82acb68994e7878fe822f1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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/<filename>')
def server_static(filename):
      return static_file(filename, root='./dithers/')

@route('/img/<filename>')
def server_static(filename):
      return static_file(filename, root='./img/')

@route('/<filename>')
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)