blob: 64a91ca377291635e402ad319d48827554d77d86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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()
|