-
Notifications
You must be signed in to change notification settings - Fork 0
/
matt-daemon.py
33 lines (28 loc) · 910 Bytes
/
matt-daemon.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
#!/usr/bin/env python3
import sys
import http.server
import socketserver
ADDRESS = "0.0.0.0"
PORT = 3333
if len(sys.argv) >= 3:
ADDRESS = sys.argv[1]
PORT = int(sys.argv[2])
elif len(sys.argv) >= 2:
PORT = int(sys.argv[1])
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer((ADDRESS, PORT), Handler) as httpd:
try:
print("\033[92m")
print("You can now view this direcotry in the browser:")
print("\033[0m")
print(" http://localhost:\033[1m{0}".format(PORT))
print("\033[0m\033[1m")
print("Note that Matt Daemon is not recommended for production.")
print("It only implements basic security checks.")
print("\033[0m")
httpd.serve_forever()
except KeyboardInterrupt as e:
httpd.shutdown()
print("\033[91m")
print("Matt Daemon terminated.")
print("\033[0m")