#!{{ python_executable }} import cgi import cgitb import ConfigParser import os import re import subprocess from IPython.lib import passwd #cgitb.enable(display=0, logdir="/tmp/cgi.log") cgitb.enable() form = cgi.FieldStorage() config_file = "{{ config_cfg }}" if not os.path.exists(config_file): print "Your software does not embed 0-knowledge. \ This interface is useless in this case" exit(0) parser = ConfigParser.ConfigParser() parser.read(config_file) if not parser.has_section("jupyter_notebook"): parser.add_section("jupyter_notebook") if not parser.has_option("jupyter_notebook", "password"): parser.set("jupyter_notebook", "password", "") if "password" in form: parser.set("jupyter_notebook", "password", passwd(form["password"].value)) # subprocess.call('{{ httpd_graceful }}') # TODO: we should restart jupyter with open(config_file, 'w') as file: parser.write(file) # TODO cleanup print "" print "" print "" print "" print "

Jupyter Notebook Password :

" print "
" print "" print """


"""