#!/usr/bin/python3 import cgi import cgitb import datetime cgitb.enable(display=0, logdir="/var/log/onboard") # Create instance of FieldStorage form = cgi.FieldStorage() # Get data from fields if form.getvalue('username'): username = form.getvalue('username') else: username = "username" if form.getvalue('gecos'): gecos = form.getvalue('gecos') else: gecos = "gecos" if form.getvalue('sshkey'): sshkey = form.getvalue('sshkey') else: sshkey = "no_sshkey entered" mmss = datetime.datetime.now().strftime("%M%S") f = open("/var/www/onboard/file/%s.text" % mmss, "a") f.write("# #k:v, #k:v, separator, line(s)\n") f.write("#username: %s\n"% username) f.write("#gecos: %s\n"% gecos) f.write("# -- SSH public key(s) --\n") f.write("%s\n"% sshkey) f.close() print("Content-type:text/html") print() # separator print("") print("
") print("Hello %s
" % username) print('There is now file/%s.text.
' % (mmss,mmss)) print("It has to be further processed, outside this web form stuff
") print('') print("") print("")