blob: 3c6ddb915674c74646b57e7ec4cc1349e64defef (
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
34
35
36
|
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 main(*args):
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()
print __name__
if __name__ == '__main__':
main()
|