~curtin-dev/curtin/trunk

« back to all changes in this revision

Viewing changes to tools/webserv

  • Committer: Scott Moser
  • Date: 2017-12-20 17:33:03 UTC
  • Revision ID: smoser@ubuntu.com-20171220173303-29gha5qb8wpqrd40
README: Mention move of revision control to git.

curtin development has moved its revision control to git.
It is available at
  https://code.launchpad.net/curtin

Clone with
  git clone https://git.launchpad.net/curtin
or
  git clone git+ssh://git.launchpad.net/curtin

For more information see
  http://curtin.readthedocs.io/en/latest/topics/development.html

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python3
2
 
# python2 or python3 web server.
3
 
# Usage: webserv [port [dir]]
4
 
#  run a webserver serving 'dir' at root on 'port'
5
 
#
6
 
#  port defaults to 8000
7
 
#  dir defaults to current dir.
8
 
import os
9
 
import socket
10
 
import sys
11
 
try:
12
 
    from BaseHTTPServer import HTTPServer
13
 
    from SimpleHTTPServer import SimpleHTTPRequestHandler
14
 
except ImportError:
15
 
    from http.server import HTTPServer, SimpleHTTPRequestHandler
16
 
 
17
 
 
18
 
class HTTPServerV6(HTTPServer):
19
 
    address_family = socket.AF_INET6
20
 
 
21
 
 
22
 
if __name__ == "__main__":
23
 
    port = 8000
24
 
    if len(sys.argv) > 1:
25
 
        port = int(sys.argv[1])
26
 
    if len(sys.argv) > 2:
27
 
        dir = sys.argv[2]
28
 
        os.chdir(dir)
29
 
    server = HTTPServerV6(("::", port), SimpleHTTPRequestHandler)
30
 
    # AF_INET6 address family, a four-tuple (host, port, flowinfo, scopeid)
31
 
    host, port, flowinfo, scopeid = server.socket.getsockname()
32
 
    sys.stdout.write("%s %s\n" % (host, port))
33
 
    sys.stdout.flush()
34
 
    server.serve_forever()