forked from ConnorXploit/hackingtoolsgui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
52 lines (42 loc) · 1.45 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import subprocess, time, argparse, os, requests, sys
python_version = "python"
if 'DYNO' in os.environ:
python_version = "python3"
# if not os.name == 'nt':
# if not os.geteuid() == 0:
# sys.exit("\nOnly root can run this script\n")
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--port', help="set django server port")
args = parser.parse_args()
port = int(os.environ.get('PORT', 2222))
if args.port:
port = int(args.port)
menu = """
==============================
| Welcome to HackingToolsGUI |
|----------------------------|
| Initiating Django Server |
|----------------------------|
| http://127.0.0.1:{p}/{spaces}|
==============================
""".format(p=port, spaces=' '[len(str(port)):])
p = None
want_exit = False
want_update = False
while not want_exit:
if want_update:
print('Updating...')
p = subprocess.call(['bash', 'server_updater.sh'])
want_update = False
try:
if not p:
print(menu)
p = subprocess.call([python_version, 'manage.py', 'runserver', '0.0.0.0:{p}'.format(p=port)])
time.sleep(2)
except KeyboardInterrupt:
res = input('[DJANGO AUTO-RESTARTER] - Want to close autoloader or update? (N/y/u): ')
# Create a function for upload to pypi automatically and change versions
if res == 'y':
want_exit = True
if res == 'u':
want_update = True