-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_backend.py
More file actions
50 lines (43 loc) · 1.48 KB
/
Copy pathstart_backend.py
File metadata and controls
50 lines (43 loc) · 1.48 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
#!/usr/bin/env python3
"""
Startup script for the Fake News Detector backend
"""
import os
import sys
import subprocess
from pathlib import Path
def main():
# Change to backend directory
backend_dir = Path(__file__).parent / "backend"
os.chdir(backend_dir)
# Check if requirements are installed
try:
import fastapi
import uvicorn
print("✅ Dependencies are installed")
except ImportError:
print("❌ Installing dependencies...")
subprocess.run([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
# Check for environment file
env_file = Path(".env")
if not env_file.exists():
print("⚠️ No .env file found. Please create one from env.example")
print(" You need to add your GEMINI_API_KEY and SERPAPI_API_KEY")
print(" The server will start but API features may not work without keys.")
# Start the server
print("🚀 Starting Fake News Detector backend server...")
print(" Server will be available at: http://localhost:8000")
print(" API docs will be available at: http://localhost:8000/docs")
print(" Press Ctrl+C to stop the server")
try:
subprocess.run([
sys.executable, "-m", "uvicorn",
"main:app",
"--reload",
"--host", "0.0.0.0",
"--port", "8000"
])
except KeyboardInterrupt:
print("\n👋 Server stopped")
if __name__ == "__main__":
main()