def submitfile(): if 'username' in session and session['username'] in configs.admin: filename_saved = ''.join( random.choice(string.ascii_lowercase + string.digits) for _ in range(16)) while dbhandler.col_uploads.count({"filename_saved": filename_saved}): filename_saved = ''.join( random.choice(string.ascii_lowercase + string.digits) for _ in range(16)) file = request.files['file'] if file: filename_real = file.filename file.save('./uploads/' + filename_saved) dbfile = { 'filename_real': filename_real, 'filename_saved': filename_saved, 'size': os.path.getsize('./uploads/' + filename_saved) } dbhandler.col_uploads.insert_one(dbfile) return newrender( 'title_file', '', 'upload_result.html', '', {'url': configs.default_url + '/uploads/' + filename_saved}) return newrender('title_file', 'Error') else: return error_handler.error_404(0)
def submitfile(): if 'username' in session and session['username'] in configs.admin: filename_saved = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16)) while dbhandler.col_uploads.count({"filename_saved": filename_saved}): filename_saved = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16)) file = request.files['file'] if file: filename_real=file.filename file.save('./uploads/' + filename_saved) dbfile = { 'filename_real': filename_real, 'filename_saved': filename_saved, 'size': os.path.getsize('./uploads/' + filename_saved) } dbhandler.col_uploads.insert_one(dbfile) return newrender('title_file', '', 'upload_result.html', '', {'url': configs.default_url + '/uploads/' + filename_saved}) return newrender('title_file', 'Error') else: return error_handler.error_404(0)
def upload(): if 'username' in session and session['username'] in configs.admin: return newrender('title_file', '', 'upload.html') else: return error_handler.error_404(0)