forked from rothos/chebsite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSERVE.py
More file actions
28 lines (22 loc) · 746 Bytes
/
SERVE.py
File metadata and controls
28 lines (22 loc) · 746 Bytes
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
from __future__ import print_function
import os
try:
# Python 3 HTTP server libraries.
from http.server import SimpleHTTPRequestHandler
from socketserver import TCPServer
except ImportError:
# Python 2 HTTP server libraries.
from SimpleHTTPServer import SimpleHTTPRequestHandler
from SocketServer import TCPServer
def serve():
"""HTTP server straight from the docs."""
# allow running this from the top level
if os.path.isdir('_build'):
os.chdir('_build')
# local use, address reuse should be OK
TCPServer.allow_reuse_address = True
PORT = 8000
httpd = TCPServer(('', PORT), SimpleHTTPRequestHandler)
print("Serving at port {}".format(PORT))
httpd.serve_forever()
serve()