2020-02-28 05:25:17 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
2017-04-10 17:16:56 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2020-02-28 05:25:17 +00:00
|
|
|
import http.server
|
|
|
|
import socketserver
|
2011-08-19 23:43:21 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
path = os.path.dirname(sys.argv[0])
|
|
|
|
os.chdir(path)
|
|
|
|
os.chdir('..')
|
|
|
|
os.chdir('build-doc/output/html')
|
|
|
|
|
2020-02-28 05:25:17 +00:00
|
|
|
class ReusingTCPServer(http.server.SimpleHTTPRequestHandler):
|
2011-08-19 23:43:21 +00:00
|
|
|
allow_reuse_address = True
|
|
|
|
|
|
|
|
def send_head(self):
|
|
|
|
# horrible kludge because SimpleHTTPServer is buggy wrt
|
|
|
|
# slash-redirecting of requests with query arguments, and will
|
|
|
|
# redirect to /foo?q=bar/ -- wrong slash placement
|
|
|
|
self.path = self.path.split('?', 1)[0]
|
2020-02-28 05:25:17 +00:00
|
|
|
return http.server.SimpleHTTPRequestHandler.send_head(self)
|
2011-08-19 23:43:21 +00:00
|
|
|
|
2020-02-28 05:25:17 +00:00
|
|
|
httpd = socketserver.TCPServer(
|
2011-08-19 23:43:21 +00:00
|
|
|
("", 8080),
|
|
|
|
ReusingTCPServer,
|
|
|
|
)
|
|
|
|
try:
|
2017-04-10 17:16:56 +00:00
|
|
|
print("Serving doc at port: http://localhost:8080")
|
2011-08-19 23:43:21 +00:00
|
|
|
httpd.serve_forever()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
pass
|