示例#1
0
    def GET(self, *args, **kwargs):
        cherrypy.response.headers["Content-Type"] = "application/json"

        if not args:
            raise cherrypy.HTTPError(404, 'No argument specified.')

        path = '/'.join(args)
        try:
            obj = Photo(os.path.join(self.rootpath, path))
        except OSError:
            raise cherrypy.HTTPError(404)

        return obj.serialize(recursive=False)
示例#2
0
    def GET(self, *args, **kwargs):
        if not args:
            raise cherrypy.HTTPError(500, 'No arguments specified.')

        if not args[0].isdigit():
            if args[0] != "orig":
                raise cherrypy.HTTPError(500, "Invalid argument.")

        path = '/'.join(args)
        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()