-
Notifications
You must be signed in to change notification settings - Fork 4
/
authserver.py
53 lines (38 loc) · 1.01 KB
/
authserver.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python
import SimpleHTTPServer
import SocketServer
from socket import SHUT_RDWR
import logging
import cgi
import sys
if len(sys.argv) > 2:
PORT = int(sys.argv[2])
I = sys.argv[1]
elif len(sys.argv) > 1:
PORT = int(sys.argv[1])
I = ""
else:
PORT = 8123
I = ""
class Server(SocketServer.TCPServer):
keep_serving = True
allow_reuse_address = 1
def serve_until_dismissed(self):
while self.keep_serving:
self.handle_request()
self.server_close()
def server_close(self):
self.socket.close()
class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/plain")
self.end_headers()
self.wfile.write(self.path)
print self.path
self.server.keep_serving = False
def log_message(self, format, *args):
pass
Handler = ServerHandler
httpd = Server(("", PORT), Handler)
httpd.serve_until_dismissed()