amauricunha commited on
Commit
ae4ab1f
Β·
verified Β·
1 Parent(s): 87f6e1c

Delete run.py

Browse files
Files changed (1) hide show
  1. run.py +0 -95
run.py DELETED
@@ -1,95 +0,0 @@
1
- # run.py - Production startup script for English Helper
2
-
3
- import os
4
- import sys
5
- from app import app
6
- from database import init_db
7
-
8
- def setup_environment():
9
- """Setup environment variables and configuration"""
10
- # Set default environment variables if not present
11
- if not os.environ.get('SECRET_KEY'):
12
- os.environ['SECRET_KEY'] = 'dev-key-change-in-production'
13
-
14
- # Create data directory if it doesn't exist
15
- data_dir = os.path.join(os.path.dirname(__file__), 'data')
16
- if not os.path.exists(data_dir):
17
- os.makedirs(data_dir)
18
-
19
- print("βœ… Environment setup complete")
20
-
21
- def initialize_database():
22
- """Initialize the database"""
23
- try:
24
- init_db()
25
- print("βœ… Database initialized successfully")
26
- except Exception as e:
27
- print(f"❌ Database initialization failed: {e}")
28
- sys.exit(1)
29
-
30
- def check_dependencies():
31
- """Check if all required dependencies are installed"""
32
- required_packages = [
33
- 'flask', 'flask_session', 'gtts', 'groq', 'google.generativeai',
34
- 'requests', 'PIL', 'werkzeug', 'email_validator', 'beautifulsoup4',
35
- 'feedparser', 'matplotlib', 'plotly', 'pandas', 'numpy'
36
- ]
37
-
38
- missing_packages = []
39
- for package in required_packages:
40
- try:
41
- if package == 'PIL':
42
- import PIL
43
- elif package == 'google.generativeai':
44
- import google.generativeai
45
- else:
46
- __import__(package)
47
- except ImportError:
48
- missing_packages.append(package)
49
-
50
- if missing_packages:
51
- print(f"❌ Missing required packages: {', '.join(missing_packages)}")
52
- print("Install them with: pip install -r requirements.txt")
53
- return False
54
-
55
- print("βœ… All dependencies are installed")
56
- return True
57
-
58
- def startup_checks():
59
- """Perform startup checks"""
60
- print("πŸš€ Starting English Helper...")
61
- print("=" * 50)
62
-
63
- # Check dependencies
64
- if not check_dependencies():
65
- print("Please install missing dependencies and try again.")
66
- sys.exit(1)
67
-
68
- # Setup environment
69
- setup_environment()
70
-
71
- # Initialize database
72
- initialize_database()
73
-
74
- print("=" * 50)
75
- print("βœ… All startup checks passed!")
76
- print("🌐 Starting Flask application...")
77
-
78
- if __name__ == '__main__':
79
- startup_checks()
80
-
81
- # Get configuration from environment
82
- debug = os.environ.get('FLASK_DEBUG', 'False').lower() == 'true'
83
- port = int(os.environ.get('PORT', 5000))
84
- host = os.environ.get('HOST', '127.0.0.1')
85
-
86
- print(f"πŸ“‘ Server starting on http://{host}:{port}")
87
- print("🎯 Press Ctrl+C to stop the server")
88
-
89
- # Start the Flask application
90
- app.run(
91
- host=host,
92
- port=port,
93
- debug=debug,
94
- threaded=True
95
- )