def POST(self): """ Store uploaded file. """ try: i = web.input(file={}, name='No Name') except ValueError: return render.error(message='Sorry, only files up to %d' ' megabytes are accepted.' % MAX_UPLOAD_SIZE) # Check if we have everything we need if not 'file' in i or i.file == None or not i.file.file or not i.name: return render.error(message='No name and/or file provided.') # Store the file under a temporary path fd, filename = tempfile.mkstemp(suffix='.vcf', prefix='upload-') handle = os.fdopen(fd, 'w') handle.write(i.file.file.read()) handle.close() web.seeother('/thanks?%s' % urlencode({'file': filename, 'name': i.name}))
def POST(self): """ Store uploaded file. """ try: i = web.input(file={}, name='No Name') except ValueError: return render.error(message='Sorry, only files up to %d' ' megabytes are accepted.' % MAX_UPLOAD_SIZE) # Check if we have everything we need if not 'file' in i or i.file == None or not i.file.file or not i.name: return render.error(message='No name and/or file provided.') # Store the file under a temporary path fd, filename = tempfile.mkstemp(suffix='.vcf', prefix='upload-') handle = os.fdopen(fd, 'w') handle.write(i.file.file.read()) handle.close() web.seeother('/thanks?%s' % urlencode({ 'file': filename, 'name': i.name }))
def url_encode(url): return http.urlencode(url)
def GET(self, path): fragments = '' if web.input(): fragments = '?' + http.urlencode(web.input()) return web.seeother('/' + path + '/' + fragments)