-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserve.py
More file actions
28 lines (21 loc) · 734 Bytes
/
Copy pathserve.py
File metadata and controls
28 lines (21 loc) · 734 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
"""
CRUCIBLE Demo Server
Serves the demo app + data files.
Usage: python serve.py [--port 8080]
"""
import argparse
import http.server
import os
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--port", type=int, default=8080)
args = parser.parse_args()
os.chdir(os.path.dirname(os.path.abspath(__file__)))
handler = http.server.SimpleHTTPRequestHandler
handler.extensions_map.update({".js": "application/javascript", ".json": "application/json"})
with http.server.HTTPServer(("", args.port), handler) as httpd:
print(f"CRUCIBLE demo: http://localhost:{args.port}/demo/")
print("Ctrl+C to stop")
httpd.serve_forever()
if __name__ == "__main__":
main()