-
Notifications
You must be signed in to change notification settings - Fork 0
/
HTTPServer.py
30 lines (25 loc) · 777 Bytes
/
HTTPServer.py
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
29
30
#!/usr/bin/env python3
import http.server
import socketserver
PORT = 8000
class HttpRequestHandler(http.server.SimpleHTTPRequestHandler):
extensions_map = {
'': 'application/octet-stream',
'.css': 'text/css',
'.html': 'text/html',
'.jpg': 'image/jpg',
'.js':'application/x-javascript',
'.json': 'application/json',
'.manifest': 'text/cache-manifest',
'.pdf': 'application/pdf',
'.png': 'image/png',
'.svg': 'image/svg+xml',
'.wasm': 'application/wasm',
'.xml': 'application/xml',
}
httpd = socketserver.TCPServer(("localhost", PORT), HttpRequestHandler)
try:
print(f"serving at http://localhost:{PORT}")
httpd.serve_forever()
except KeyboardInterrupt:
pass