forked from benjaminp/httpswatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting_server.py
More file actions
23 lines (17 loc) · 747 Bytes
/
testing_server.py
File metadata and controls
23 lines (17 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#/usr/bin/env python3
import argparse
from http import server as httpserver
class TestingRequestHandler(httpserver.SimpleHTTPRequestHandler):
def translate_path(self, path):
if not path.startswith("/static/"):
path = "/out" + path + ".html"
return super(TestingRequestHandler, self).translate_path(path)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('port', action='store',
default=8000, type=int,
nargs='?',
help='Specify alternate port [default: 8000]')
args = parser.parse_args()
handler_class = TestingRequestHandler
httpserver.test(HandlerClass=handler_class, port=args.port)