Index: /nodes/gformat.py
===================================================================
--- /nodes/gformat.py	(revision 8258)
+++ /nodes/gformat.py	(revision 8259)
@@ -29,5 +29,5 @@
 def print_title(nodelist):
   """ Main overview page """
-  items = {'root' : os.environ['SCRIPT_NAME'] } 
+  items = {'root' : "." } 
   print """
 <html>
@@ -43,5 +43,5 @@
   <body>
     <center>
-    <form type="GET" action="">
+    <form type="GET" action="%(root)s">
       <input type="hidden" name="action" value="update">
       <input type="submit" value="Update Configuration Database (SVN)">
@@ -331,5 +331,5 @@
   form = cgi.FieldStorage()
   if form.getvalue("action") == "update":
-    print "Refresh: 5; url=%s" % os.environ['SCRIPT_NAME']
+    print "Refresh: 5; url=."
     print "Content-type:text/plain\r\n\r\n",
     print "[INFO] Updating subverion, please wait..."
@@ -354,8 +354,52 @@
     assert False, "Invalid option"
 
+
+
+def usage():
+  print """Usage: %s <standalone [port] |test [test arguments]>
+Examples:
+\tstandalone                   =  Run configurator webserver [default port=8000]
+\ttest CNodeRick dnsmasq.conf  =  Receive output of CGI script 
+\t                                for arguments CNodeRick/dnsmasq.conf
+"""
+  exit(0)
+
+
+
 # Allow easy hacking using the CLI
 if not os.environ.has_key('PATH_INFO'):
-  os.environ['PATH_INFO'] = "/".join(sys.argv[1:])
-  os.environ['SCRIPT_NAME'] = __file__
-
-process_cgi_request()
+  if len(sys.argv) < 2:
+    usage()
+
+  if sys.argv[1] == "standalone":
+    import SocketServer
+    import CGIHTTPServer
+    try:
+      PORT = int(sys.argv[2])
+    except (IndexError,ValueError):
+      PORT = 8000
+
+    class MyCGIHTTPRequestHandler(CGIHTTPServer.CGIHTTPRequestHandler):
+      """ Serve this CGI from the root of the webserver """
+      def is_cgi(self):
+        if "favicon" in self.path:
+          return False
+
+        self.cgi_info = (__file__, self.path)
+        self.path = ''
+        return True
+    handler = MyCGIHTTPRequestHandler
+    httpd = SocketServer.TCPServer(("", PORT), handler)
+    httpd.server_name = 'localhost'
+    httpd.server_port = PORT
+    
+    print "serving at port", PORT
+    httpd.serve_forever()
+  elif sys.argv[1] == "test":
+    os.environ['PATH_INFO'] = "/".join(sys.argv[2:])
+    os.environ['SCRIPT_NAME'] = __file__
+    process_cgi_request()
+  else:
+    usage()
+else:
+  process_cgi_request()
