~ubuntu-branches/ubuntu/natty/lightning-extension/natty-security

« back to all changes in this revision

Viewing changes to mozilla/testing/mozbase/mozhttpd/mozhttpd/mozhttpd.py

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-09-03 14:00:01 UTC
  • mfrom: (1.1.24)
  • Revision ID: package-import@ubuntu.com-20120903140001-iee9509f51oz7pqs
Tags: 1.8+build1-0ubuntu0.11.04.1
* New upstream stable release to support Thunderbird 16 (CALENDAR_1_8_BUILD1)
  - LP: #1062587

* Add extra Makefiles that are needed for the build
  - update debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
 
3
3
# This Source Code Form is subject to the terms of the Mozilla Public
4
 
# License, v. 2.0. If a copy of the MPL was not distributed with this
5
 
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
4
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
 
5
# You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
 
7
7
import BaseHTTPServer
8
8
import SimpleHTTPServer
16
16
import urllib
17
17
import urlparse
18
18
import re
 
19
import iface
19
20
from SocketServer import ThreadingMixIn
20
21
 
21
22
class EasyServer(ThreadingMixIn, BaseHTTPServer.HTTPServer):
224
225
 
225
226
 
226
227
def main(args=sys.argv[1:]):
227
 
    
 
228
 
228
229
    # parse command line options
229
230
    from optparse import OptionParser
230
231
    parser = OptionParser()
231
 
    parser.add_option('-p', '--port', dest='port', 
 
232
    parser.add_option('-p', '--port', dest='port',
232
233
                      type="int", default=8888,
233
234
                      help="port to run the server on [DEFAULT: %default]")
234
235
    parser.add_option('-H', '--host', dest='host',
235
236
                      default='127.0.0.1',
236
237
                      help="host [DEFAULT: %default]")
 
238
    parser.add_option('-i', '--external-ip', action="store_true",
 
239
                      dest='external_ip', default=False,
 
240
                      help="find and use external ip for host")
237
241
    parser.add_option('-d', '--docroot', dest='docroot',
238
242
                      default=os.getcwd(),
239
243
                      help="directory to serve files from [DEFAULT: %default]")
240
244
    options, args = parser.parse_args(args)
241
245
    if args:
 
246
        parser.error("mozhttpd does not take any arguments")
242
247
        parser.print_help()
243
248
        parser.exit()
244
249
 
 
250
    if options.external_ip:
 
251
        host = iface.get_lan_ip()
 
252
    else:
 
253
        host = options.host
 
254
 
245
255
    # create the server
246
 
    kwargs = options.__dict__.copy()
247
 
    server = MozHttpd(**kwargs)
 
256
    server = MozHttpd(host=host, port=options.port, docroot=options.docroot)
248
257
 
249
258
    print "Serving '%s' at %s:%s" % (server.docroot, server.host, server.port)
250
259
    server.start(block=True)