Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
# Bihar districts list
|
6 |
BIHAR_DISTRICTS = [
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
from datetime import datetime
|
4 |
+
import subprocess
|
5 |
+
import threading
|
6 |
+
import time
|
7 |
+
|
8 |
+
# Start the MCP server
|
9 |
+
def start_server():
|
10 |
+
"""Start the MCP server"""
|
11 |
+
try:
|
12 |
+
process = subprocess.Popen([
|
13 |
+
"uvicorn", "server:app",
|
14 |
+
"--host", "0.0.0.0",
|
15 |
+
"--port", "8000"
|
16 |
+
])
|
17 |
+
return process
|
18 |
+
except Exception as e:
|
19 |
+
print(f"Failed to start server: {e}")
|
20 |
+
return None
|
21 |
+
|
22 |
+
# Start server in background thread
|
23 |
+
print("🚀 Starting MCP server...")
|
24 |
+
server_thread = threading.Thread(target=start_server, daemon=True)
|
25 |
+
server_thread.start()
|
26 |
+
|
27 |
+
# Wait for server to start
|
28 |
+
print("⏳ Waiting for server to start...")
|
29 |
+
time.sleep(10)
|
30 |
|
31 |
# Bihar districts list
|
32 |
BIHAR_DISTRICTS = [
|