-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
106 lines (88 loc) · 2.75 KB
/
run.py
File metadata and controls
106 lines (88 loc) · 2.75 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
"""
Convenience script to run the SPARC application
This checks prerequisites before starting
"""
import os
import sys
def check_env():
"""Check if .env file exists and has required variables"""
if not os.path.exists('.env'):
print("❌ Error: .env file not found!")
print("\nPlease create a .env file with:")
print(" FLASK_SECRET_KEY=your-secret-key")
print(" LINKEDIN_USERNAME=your-email")
print(" LINKEDIN_PASSWORD=your-password")
print(" GITHUB_TOKEN=your-token")
print(" GEMINI_API_KEY=your-api-key")
print("\nSee QUICK_START.md for details.")
return False
required_vars = [
'FLASK_SECRET_KEY',
'GITHUB_TOKEN',
'GEMINI_API_KEY'
]
from dotenv import dotenv_values
config = dotenv_values('.env')
missing = [var for var in required_vars if not config.get(var)]
if missing:
print(f"❌ Missing required variables in .env: {', '.join(missing)}")
return False
print("✓ Environment variables configured")
return True
def check_directories():
"""Check if required directories exist"""
required_dirs = [
'application/app/user_data',
'chatbot',
'static/css',
'static/js',
'templates'
]
missing = [d for d in required_dirs if not os.path.exists(d)]
if missing:
print(f"❌ Missing directories: {', '.join(missing)}")
print("Run: python setup.py")
return False
print("✓ Directory structure OK")
return True
def check_dependencies():
"""Check critical dependencies"""
try:
import flask
import selenium
import langchain
import chromadb
print("✓ Dependencies installed")
return True
except ImportError as e:
print(f"❌ Missing dependency: {e.name}")
print("Run: pip install -r requirements.txt")
return False
def main():
print("=" * 60)
print("🚀 STARTING SPARC APPLICATION")
print("=" * 60)
print()
# Run checks
checks = [
check_env(),
check_directories(),
check_dependencies()
]
if not all(checks):
print("\n❌ Prerequisites not met. Please fix the issues above.")
sys.exit(1)
print("\n✅ All checks passed! Starting Flask application...")
print("=" * 60)
print()
# Import and run the app
try:
from app import app
print("📍 Open your browser to: http://localhost:5000")
print("Press CTRL+C to stop the server\n")
app.run(debug=True, port=5000)
except Exception as e:
print(f"\n❌ Error starting application: {e}")
sys.exit(1)
if __name__ == "__main__":
main()