elanuk commited on
Commit
06cdcc5
·
verified ·
1 Parent(s): 427730f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -2
app.py CHANGED
@@ -3,9 +3,36 @@ import requests
3
  import json
4
  from datetime import datetime
5
  import os
 
 
 
6
 
7
- # Configuration
8
- MCP_SERVER_URL = os.getenv("MCP_SERVER_URL", "https://elanuk-mcp-hf.hf.space/")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # Bihar districts list
11
  BIHAR_DISTRICTS = [
 
3
  import json
4
  from datetime import datetime
5
  import os
6
+ import subprocess
7
+ import threading
8
+ import time
9
 
10
+ # Configuration - for HuggingFace Spaces
11
+ MCP_SERVER_URL = "https://elanuk-mcp-hf.hf.space/" # Local server URL
12
+
13
+ def start_mcp_server():
14
+ """Start the MCP server in background"""
15
+ try:
16
+ # Start mcp_server.py as subprocess
17
+ process = subprocess.Popen(
18
+ ["python", "mcp_server.py"],
19
+ stdout=subprocess.PIPE,
20
+ stderr=subprocess.PIPE
21
+ )
22
+
23
+ # Wait a bit for server to start
24
+ time.sleep(10)
25
+ return process
26
+ except Exception as e:
27
+ print(f"Failed to start MCP server: {e}")
28
+ return None
29
+
30
+ # Start server in background thread
31
+ def start_server_thread():
32
+ start_mcp_server()
33
+
34
+ server_thread = threading.Thread(target=start_server_thread, daemon=True)
35
+ server_thread.start()
36
 
37
  # Bihar districts list
38
  BIHAR_DISTRICTS = [