Just got my iPad yesterday and could not wait to try this app.
I created a basic gallery using bottle getting to know some Python.
I really just want to say thanks for creating such an awesome app!
from bottle import route, run, template, response
import photos
import json
import StringIO
def imageHeader(resp):
resp.set_header('Content-Type','image/jpeg')
resp.set_header('Content-Disposition','attachment; filename=img.jpg')
@route('/image/<id:int>')
def image(id):
imageHeader(response)
return photos.get_image(id, True ,True)
@route('/thumb/<id:int>')
def thumb(id):
imageHeader(response)
buff = StringIO.StringIO()
buff.seek(0)
photos.get_thumbnail(id).save(buff, format='jpeg')
val = buff.getvalue()
buff.close()
return val
@route('/meta/<id:int>')
def meta(id):
response.set_header('Content-Type','application/json')
return json.dumps(photos.get_metadata(id))
# by ccc
@route('/')
def index():
fmt = '<a href="/image/{}"><img src="/thumb/{}" width="75" height="75"/></a>\n'
return [fmt.format(x, x) for x in xrange(photos.get_count())]
run(host='localhost', port=8080)