Welcome to mirror list, hosted at ThFree Co, Russian Federation.

simple_http_server.py « tools - github.com/certbot/certbot.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 14ac9a3d37c06f30134a29700968cb96aa7c39ac (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
#!/usr/bin/env python
"""A version of Python 2.x's SimpleHTTPServer that flushes its output."""
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import sys

def serve_forever(port=0):
    """Spins up an HTTP server on all interfaces and the given port.

    A message is printed to stdout specifying the address and port being used
    by the server.

    :param int port: port number to use.

    """
    server = HTTPServer(('', port), SimpleHTTPRequestHandler)
    print('Serving HTTP on {0} port {1} ...'.format(*server.server_address))
    sys.stdout.flush()
    server.serve_forever()


if __name__ == '__main__':
    kwargs = {}
    if len(sys.argv) > 1:
        kwargs['port'] = int(sys.argv[1])
    serve_forever(**kwargs)