Exemplo n.º 1
0
    def post(self):
        stream_id = self.request.get('stream_id')
        template = JINJA_ENVIRONMENT.get_template('error.html')

        data = {}
        if not Stream.get_by_id(stream_id):
            data['msg'] = 'Stream id %s not found!' % stream_id
            return self.response.write(template.render(data))
        if not self.request.get('files[]'):
            data['msg'] = 'Hey, Upload an image first!'
            return self.response.write(template.render(data))

        results = []
        for img in self.request.get_all('files[]'):
            results.append({'name': '', 'url': '', 'type': '', 'size': 64})
            avatar = images.resize(img, 320, 320)
            lat = self.request.get('lat')
            lat = float(lat) if lat else None
            lng = self.request.get('lng')
            lng = float(lng) if lng else None
            image = Image(data=db.Blob(avatar),
                          comment=self.request.get('comment'),
                          lat=lat,
                          lng=lng).put()
            Stream.append_image(stream_id, image)
        s = json.dumps({'files': results}, separators=(',', ':'))
        self.response.headers['Content-Type'] = 'application/json'
        return self.response.write(s)
Exemplo n.º 2
0
    def post(self):
        stream_id = self.request.get('stream_id')
        template = JINJA_ENVIRONMENT.get_template('error.html')

        data = {}
        if not Stream.get_by_id(stream_id):
            data['msg'] = 'Stream id %s not found!' % stream_id
            return self.response.write(template.render(data))
        if not self.request.get('files[]'):
            data['msg'] = 'Hey, Upload an image first!'
            return self.response.write(template.render(data))

        results = []
        for img in self.request.get_all('files[]'):
            results.append({'name': '', 'url': '', 'type': '', 'size': 64})
            avatar = images.resize(img, 320, 320)
            lat = self.request.get('lat')
            lat = float(lat) if lat else None
            lng = self.request.get('lng')
            lng = float(lng) if lng else None
            image = Image(data=db.Blob(avatar),
                          comment=self.request.get('comment'),
                          lat=lat, lng=lng).put()
            Stream.append_image(stream_id, image)
        s = json.dumps({'files': results}, separators=(',', ':'))
        self.response.headers['Content-Type'] = 'application/json'
        return self.response.write(s)
Exemplo n.º 3
0
 def post(self):
     stream_id = self.request.get('stream_id')
     img_blob = self.request.get('img_blob')
     template = JINJA_ENVIRONMENT.get_template('error.html')
     lat = self.request.get('lat')
     lat = float(lat) if lat else None
     lng = self.request.get('lng')
     lng = float(lng) if lng else None
     image = Image(data=img_blob, comment=' ', lat=lat, lng=lng).put()
     #logging.error('Stream ID:%s',str(stream_id))
     Stream.append_image(stream_id, image)
Exemplo n.º 4
0
 def post(self):
     stream_id = self.request.get('stream_id')
     img_blob = self.request.get('img_blob')
     template = JINJA_ENVIRONMENT.get_template('error.html')
     lat = self.request.get('lat')
     lat = float(lat) if lat else None
     lng = self.request.get('lng')
     lng = float(lng) if lng else None
     image = Image(data=img_blob,comment=' ',lat=lat, lng=lng).put()
     #logging.error('Stream ID:%s',str(stream_id)) 
     Stream.append_image(stream_id, image)