-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhttp_server.py
More file actions
executable file
·34 lines (27 loc) · 813 Bytes
/
Copy pathhttp_server.py
File metadata and controls
executable file
·34 lines (27 loc) · 813 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
29
30
31
32
33
34
#!/usr/bin/python
# PICOTA - Simple HTTP server
# David Art [aka] ADcomp
import sys
import os
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
REALPATH = os.path.dirname(os.path.realpath(__file__))
os.chdir("%s/www" % REALPATH)
HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"
if __name__ == "__main__":
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server_address = ('127.0.0.1', port)
HandlerClass.protocol_version = Protocol
httpd = ServerClass(server_address, HandlerClass)
sockname = httpd.socket.getsockname()
print("Serving HTTP on", sockname[0], "port", sockname[1], "...")
try:
httpd.serve_forever()
except KeyboardInterrupt:
print('\nExit ..')
sys.exit(0)