Example #1
0
 def POST(self):
     x = web.input(myfile={})
     filename = x['myfile'].filename
     data = x['myfile'].value
     try:
         url = hws_upload(filename, data)
         return url_template(url)
     except Exception, e:
         web.debug(str(e))
         set_status_code(web, 500)
         return exception_template(e)
Example #2
0
    def POST(self):
        web.header('Content-Type', 'text/json')

        body = web.data()
        if body is None:
            set_status_code(web, 400)
            return result_template('empty body')
        split = body.find('\r\n')
        end = body.rfind('\r\n')
        if split == -1 or end == -1 or split == end:
            set_status_code(web, 400)
            return result_template('invalid body')

        filename = body[0:split]
        data = body[split + 2:end]
        try:
            url = hws_upload(filename, data)
            return url_template(url)
        except Exception, e:
            set_status_code(web, 500)
            return exception_template(e)