From e012917ceb8b694d2a21f8aafa3359946eacbd42 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 24 Feb 2009 19:30:05 -0400 Subject: Created some new Python scripts under python/ --- python/server.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 python/server.py (limited to 'python/server.py') diff --git a/python/server.py b/python/server.py new file mode 100644 index 00000000..64a91ca3 --- /dev/null +++ b/python/server.py @@ -0,0 +1,33 @@ +import ledger +import cgi +import sys + +from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer + +class LedgerHandler(BaseHTTPRequestHandler): + def do_GET(self): + print "Saw a GET request!" + sys.exit(0) + + def do_POST(self): + print "Saw a POST request!" + try: + ctype, pdict = cgi.parse_header(self.headers.getheader('content-type')) + if ctype == 'multipart/form-data': + query = cgi.parse_multipart(self.rfile, pdict) + self.send_response(301) + self.end_headers() + except Exception: + print "Saw exception in POST handler" + +def cmd_server(): + try: + port = 9000 + server = HTTPServer(('', port), LedgerHandler) + print "Local HTTP server listening on port %d... (Control-C to exit)" \ + % port + server.serve_forever() + except KeyboardInterrupt: + print "Shutting down server" + server.socket.close() + -- cgit v1.2.3