示例#1
0
 def delete(self, filename):
     path = PATH + filename
     try:
         os.remove(path)
     except Exception:
         return error('Could not remove file ' + filename)
     return empty_result(status='success')
示例#2
0
 def get(self, filename):
     path = PATH + filename
     try:
         sha1 = file_sha1(path)
     except Exception:
         return error('Could not find file ' + filename)
     res = {'file': {'filename': filename,
                     'sha1': sha1}}
     return empty_result(status='success', data=res)
示例#3
0
    def post(self):
        json_data = request.get_json()

        if 'url' not in json_data:
            return error('URL must be specified')
        if 'sha1' not in json_data:
            return error('Checksum must be specified')
        if 'verify_tls' not in json_data:
            json_data['verify_tls'] = None

        filename = self.url_parse(json_data['url'])
        if filename == '':
            return error('Invalid URL, could not parse filename')
        res = self.file_download(json_data['url'], json_data['sha1'],
                                 filename, json_data['verify_tls'])
        if res != '':
            return error(res)
        return empty_result(status='success')
示例#4
0
 def get(self):
     files = self.files_get()
     data = {'files': files}
     return empty_result(status='success', data=data)
示例#5
0
def error(errstr):
    return empty_result(status='error', data=errstr), 404