-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_local_network.py
More file actions
50 lines (41 loc) · 1.37 KB
/
run_local_network.py
File metadata and controls
50 lines (41 loc) · 1.37 KB
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
"""
Local Network Server Runner (Basic - No Chat)
Starts the Pulsefeed on your local network for access from other devices.
NOTE: This uses Waitress (no WebSocket support). Chat features will NOT work.
For full features including chat, use: python start_network.py
Usage:
python run_local_network.py
Access from other devices:
http://<your-local-ip>:5000
"""
import socket
from waitress import serve
from app import create_app
def get_local_ip():
"""Get the local network IP address"""
try:
# Create a socket to find local IP
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
local_ip = s.getsockname()[0]
s.close()
return local_ip
except Exception:
return "localhost"
if __name__ == "__main__":
app = create_app()
local_ip = get_local_ip()
port = 5000
print("\n" + "="*60)
print("Pulsefeed - Local Network Server")
print("="*60)
print(f"\nServer starting on port {port}...")
print(f"\nAccess from this computer:")
print(f" http://localhost:{port}")
print(f" http://127.0.0.1:{port}")
print(f"\nAccess from other devices on your network:")
print(f" http://{local_ip}:{port}")
print("\nPress Ctrl+C to stop the server")
print("="*60 + "\n")
# Serve on all network interfaces
serve(app, host='0.0.0.0', port=port, threads=4)