-
Notifications
You must be signed in to change notification settings - Fork 0
/
http_server.py
executable file
·31 lines (30 loc) · 1.15 KB
/
http_server.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
31
#!/usr/bin/env python
from __future__ import print_function
import sys
import runpy
if sys.version_info.major == 2:
print("Starting SimpleHTTPServer under python {}.{}".format(sys.version_info.major, sys.version_info.minor))
import SimpleHTTPServer
import SocketServer
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
# Override MIME mapping in case system does not recognize .js as javascript
Handler.extensions_map.update({
".js": "application/javascript",
});
httpd = SocketServer.TCPServer(("", PORT), Handler)
print("serving at port", PORT)
httpd.serve_forever()
else:
print("Starting http.server under python {}.{}".format(sys.version_info.major, sys.version_info.minor))
import http.server
import socketserver
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
# Override MIME mapping in case system does not recognize .js as javascript
Handler.extensions_map.update({
".js": "application/javascript",
});
httpd = socketserver.TCPServer(("", PORT), Handler)
print("serving at port", PORT)
httpd.serve_forever()