-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.py
37 lines (31 loc) · 1.36 KB
/
Main.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
from pysrc.HTTPServer import HTTPServer
from platform import system as osname
# enter your local IP to be able to connect other devices in the same network
serveraddress = "localhost"
port = 8080
# if it's set to True, your browser doesn't start up automatically!
isDevelopmentVersion = True
allowedRequestableFileExtensions = [
".js", ".css", ".png",
".svg", ".jpg", ".css",
".json", ".ico", ".xml"
]
if __name__ == "__main__":
if not isDevelopmentVersion:
try:
from os import system # yes, I could use the webbrowser library
# but on Windows it opens up IE or Edge :(
if osname() == "Linux":
system('xdg-open http://%s:%s &> /dev/null' %
(serveraddress, port))
elif osname() == "Darwin":
system('open http://%s:%s' % (serveraddress, port))
elif osname() == "Windows":
system('start "" http://%s:%s' % (serveraddress, port))
else:
print("Can't open your browser automatically.")
print("Your OS isn't supported!")
except:
print("Can't open your browser automatically.")
print("Maybe your OS isn't supported or you don't have a browser!")
HTTPServer.startserver(HTTPServer.RequestHandler)