annotate requestdumpster/dumpster.py @ 2:8ddcab56f340

forgot an import
author Jeff Hammel <k0scist@gmail.com>
date Tue, 30 Jun 2015 16:13:09 -0700
parents 4ab07b01ee63
children f2f983b76090
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 """
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 dump HTTP requests
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 """
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
2
8ddcab56f340 forgot an import
Jeff Hammel <k0scist@gmail.com>
parents: 1
diff changeset
7 # imports
1
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 import optparse
2
8ddcab56f340 forgot an import
Jeff Hammel <k0scist@gmail.com>
parents: 1
diff changeset
9 import sys
1
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 import wsgiref
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 class RequestDumpster(object):
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 def __init__(self):
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 """placeholder"""
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17 def __call__(self, environ, start_response):
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18 """WSGI"""
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20 def main(args=sys.argv[1:]):
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21 """CLI"""
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
22
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
23 # parse command line arguments
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
24 parser = optparse.OptionParser(description=__doc__)
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
25 parser.add_option('-p', '--port', dest='port',
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
26 type='int', default=9555,
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
27 help="port to serve on")
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
28 options = parser.parse_args()
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
29
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
30 # construct url
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
31 url = 'http://localhost:{port}/'.format(port=options.port)
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
32
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
33 if __name__ == '__main__':
4ab07b01ee63 begin to stub dumpster
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
34 main()