-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlaunch_web_app.py
More file actions
64 lines (56 loc) · 2 KB
/
launch_web_app.py
File metadata and controls
64 lines (56 loc) · 2 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Smart Toilet Hygiene Prediction System - Web App Launcher
Quick launcher for the Flask web application
"""
import subprocess
import webbrowser
import time
import sys
def main():
print("🚀 Launching Smart Toilet Hygiene Prediction Web App...")
print("=" * 60)
# Check if model exists
try:
import joblib
joblib.load('hygiene_model.pkl')
print(" Trained model loaded successfully!")
except FileNotFoundError:
print(" Model not found. Training the model first...")
print("Running: python hygiene_prediction_system.py")
subprocess.run([sys.executable, 'hygiene_prediction_system.py'])
except Exception as e:
print(f"Error loading model: {e}")
return
print("\n Starting Flask web server...")
print("Web App will be available at: http://localhost:5000")
print("Analytics Dashboard: http://localhost:5000/analytics")
print("\n Features available:")
print(" • Interactive sensor controls")
print(" • Real-time hygiene predictions")
print(" • Demo scenarios (Clean/Moderate/Dirty)")
print(" • Beautiful visualizations")
print(" • Explainable AI insights")
print(" • Analytics dashboard")
print("\n⚡ Press Ctrl+C to stop the server")
print("=" * 60)
# Open browser after a short delay
def open_browser():
time.sleep(2)
webbrowser.open('http://localhost:5000')
print(" Opening web browser...")
import threading
browser_thread = threading.Thread(target=open_browser)
browser_thread.daemon = True
browser_thread.start()
# Start Flask app
try:
from app import app
app.run(debug=False, host='0.0.0.0', port=5000)
except KeyboardInterrupt:
print("\n Server stopped by user")
except Exception as e:
print(f" Error starting server: {e}")
print("Trying alternative method...")
subprocess.run([sys.executable, 'app.py'])
if __name__ == "__main__":
main()