#!/usr/bin/env python print('Content-type: text/html\n') from os.path import join, abspath from hashlib import sha1 import cgi, sys BASE_DIR = abspath('data') form = cgi.FieldStorage() text = form.getvalue('text') filename = form.getvalue('filename') password = form.getvalue('password') if not (filename and text and password): print('Invalid parameters.') sys.exit() if sha1(password.encode()).hexdigest() != '8843d7f92416211de9ebb963ff4ce28125932878': print('Invalid password') sys.exit() f = open(join(BASE_DIR,filename), 'w') f.write(text) f.close() print('The file has been saved.')