-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (26 loc) · 800 Bytes
/
main.py
File metadata and controls
32 lines (26 loc) · 800 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
from server import app, socketio
import click
from clonner import Clonner
import socket
def get_ip():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
# doesn't even have to be reachable
s.connect(('10.255.255.255', 1))
IP = s.getsockname()[0]
except Exception:
IP = '127.0.0.1'
finally:
s.close()
return IP
@click.command()
@click.option('--url', default="", help='URL for clone website')
@click.option('--port', default="5000", help='PORT for runner server')
def hello(url, port):
clonner = Clonner(url=url)
output = clonner.clone()
print(output)
print(f"Listening to new connections in port http://{get_ip()}:{port}")
socketio.run(app, host="0.0.0.0", port=port)
if __name__ == '__main__':
hello()