-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_api.py
More file actions
45 lines (36 loc) · 1.21 KB
/
run_api.py
File metadata and controls
45 lines (36 loc) · 1.21 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
#!/usr/bin/env python3
"""
Text Classification API Runner
Run the FastAPI server for text sentiment analysis
"""
import subprocess
import sys
import os
def main():
"""Run the Text Classification API"""
print("🚀 Starting Text Classification API...")
# Change to api directory
api_dir = os.path.join(os.path.dirname(__file__), "api")
if not os.path.exists(api_dir):
print("❌ API directory not found!")
sys.exit(1)
os.chdir(api_dir)
# Check if main.py exists
if not os.path.exists("main.py"):
print("❌ main.py not found in api directory!")
sys.exit(1)
# Run the API server
try:
print("📡 Starting FastAPI server on http://localhost:8000")
print("📖 API documentation: http://localhost:8000/docs")
print("🔍 Health check: http://localhost:8000/health")
print("Press Ctrl+C to stop the server")
print("-" * 50)
subprocess.run([sys.executable, "main.py"], check=True)
except KeyboardInterrupt:
print("\n👋 API server stopped")
except subprocess.CalledProcessError as e:
print(f"❌ Failed to start API server: {e}")
sys.exit(1)
if __name__ == "__main__":
main()