try: obj = Photo(os.path.join(self.rootpath, path)) except OSError: raise cherrypy.HTTPError(404) cherrypy.response.headers["Content-Type"] = "image/jpeg" return obj.getDataSmall() # Configure Autophoto 3 from ap3.core import AP3obj from ap3.serializer import PrettyJsonSerializer from ap3.cache import SingleDirectoryHashCache SingleDirectoryHashCache.setCachePath("/home/ed/tmp/ap3cache") AP3obj.setRoot("/home/ed/Documents/autophoto2") AP3obj.setSerializer(PrettyJsonSerializer) AP3obj.setCacher(SingleDirectoryHashCache) root = Root() root.album = AP3AlbumMeta("main", "/home/ed/Documents/autophoto2") root.photo = AP3PhotoMeta("/home/ed/Documents/autophoto2") root.photodata = AP3PhotoData("/home/ed/Documents/autophoto2") conf = { 'global': { 'server.socket_host': '0.0.0.0', 'server.socket_port': 8000, 'tools.gzip.on': True, 'engine.autoreload_on': True, },
#!/usr/bin/env python # -*- coding: utf-8 -*- from ap3.core import AP3obj from ap3.album import Album from ap3.photo import Photo from ap3.serializer import PrettyJsonSerializer if __name__ == "__main__": import sys if len(sys.argv) >= 2: directory = sys.argv[1] else: directory = "." AP3obj.setRoot(directory) AP3obj.setSerializer(PrettyJsonSerializer) a = Album(directory) print a.serialize(extended=True) for p in a.listMe(): if isinstance(p, Photo): pData = p.getDataMedium() if pData: print "Got p: %s dataMedium: %d" % (p, len(pData)) pData = p.getDataSmall() if pData: print "Got p: %s dataSmall: %d" % (p, len(pData))