S-Kavin-Raj/Helmet-Detection
1
1from waitress import serve2from app import app3import socket4 5def get_ip():6 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)7 try:8 s.connect(('10.255.255.255', 1))9 IP = s.getsockname()[0]10 except Exception:11 IP = '127.0.0.1'12 finally:13 s.close()14 return IP15 16if __name__ == "__main__":17 ip_address = get_ip()18 import os19 port = int(os.environ.get("PORT", 8080))20 21 print("="*50)22 print(f" PRODUCTION SERVER STARTED")23 print(f" • Local access: http://localhost:{port}")24 print(f" • Network access: http://{ip_address}:{port}")25 print("="*50)26 print("Press Ctrl+C to stop the server")27 28 serve(app, host='0.0.0.0', port=port)29 