From d31fabf8cff5dae02e3fc759a4203bd374dddc99 Mon Sep 17 00:00:00 2001 From: schneefux Date: Sun, 30 Mar 2014 16:03:44 -0400 Subject: Initial commit --- boot/app/cgi-bin/index.cgi | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 boot/app/cgi-bin/index.cgi (limited to 'boot/app/cgi-bin/index.cgi') diff --git a/boot/app/cgi-bin/index.cgi b/boot/app/cgi-bin/index.cgi new file mode 100755 index 0000000..bcb85b5 --- /dev/null +++ b/boot/app/cgi-bin/index.cgi @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +from wifi import * +import os +import cgi +import cgitb; cgitb.enable() # for troubleshooting + +# some housekeeping +print "Content-type: text/html" +print + +# get the form input +form = cgi.FieldStorage() +network = form.getvalue("network", "") +password = form.getvalue("password", "") + +# if not submitted yet, show them the network selection form +if not network: + + wifi = Wifi() + + networks = [x.replace("\n","") for x in wifi.access_points if x.replace("\n","") != "Jasper"] + select_code_split = ["" % (network, network) for network in networks] + select_code = "".join(select_code_split) + + response = open("index-template.html","r").read().replace("{{ select_code }}", select_code) + print response + +# otherwise, show them the password form +elif not password: + response = open("key-template.html","r").read().replace("{{ network }}", cgi.escape(network)) + print response + +# in the final case, process the wifi password and network data +else: + # show the confirmation page + response = open("connecting-template.html","r").read() + print response + + # save the configuration + wifi = Wifi() + wifi.add_wifi(network, password) \ No newline at end of file -- cgit v1.3.1