Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Basic Photo Gallery
-
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)
-
Really cool!! Simple but useful.
A proposed simplification of
count()
:@route('/') def count(): 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())]
-
Thanks @ccc I included it in the original posting.
Would be great if we could build a complete gallery. Including meta data and other stuff.
-
Nice this is really awesome but couldn't you just have done
photos.get_image()
I really love the bottle server though aswell