fokan commited on
Commit
69c7d0d
·
verified ·
1 Parent(s): 1bec731

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +66 -0
app.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Sequential Thinking MCP - Status</title>
6
+ <meta name="viewport" content="width=device-width,initial-scale=1">
7
+ <style>
8
+ body { font-family: Inter, Arial, sans-serif; background:#0f172a; color:#e6eef8; display:flex;align-items:center;justify-content:center;min-height:100vh; }
9
+ .card { background:linear-gradient(135deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01)); padding:24px; border-radius:12px; width:720px; box-shadow:0 6px 24px rgba(2,6,23,0.6); }
10
+ a { color: #60a5fa }
11
+ pre { background: #071029; padding:12px; border-radius:8px; overflow:auto }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <div class="card">
16
+ <h2>Sequential Thinking MCP Server</h2>
17
+ <p>حالة الخادم: <strong>{{status}}</strong></p>
18
+ <p>عنوان الخادم الداخلي: <code>http://127.0.0.1:{{mcp_port}}</code></p>
19
+ <p>روابط مفيدة:</p>
20
+ <ul>
21
+ <li><a href="/health" target="_blank">/health</a> — تحقق من استجابة MCP server</li>
22
+ <li><a href="/tools" target="_blank">/tools</a> — وصف الأدوات المكتشفة (إن وُجدت)</li>
23
+ </ul>
24
+ <hr>
25
+ <h4>ملاحظات التشغيل</h4>
26
+ <pre>لتشغيل محليًا:
27
+ docker build -t hf-seqthink .
28
+ docker run -p 7860:7860 -p 8080:8080 hf-seqthink
29
+ </pre>
30
+ </div>
31
+ </body>
32
+ </html>
33
+ """
34
+
35
+
36
+ @app.route('/')
37
+ def index():
38
+ try:
39
+ r = requests.get(f"http://127.0.0.1:{MCP_PORT}/health", timeout=1.5)
40
+ status = 'UP' if r.status_code == 200 else f'DEGRADED ({r.status_code})'
41
+ except Exception as e:
42
+ status = f'DOWN ({e})'
43
+ return render_template_string(HTML, status=status, mcp_port=MCP_PORT)
44
+
45
+
46
+ @app.route('/health')
47
+ def health():
48
+ try:
49
+ r = requests.get(f"http://127.0.0.1:{MCP_PORT}/health", timeout=1.5)
50
+ return (r.text, r.status_code, {'Content-Type': 'text/plain'})
51
+ except Exception as e:
52
+ return jsonify({'status':'down','error':str(e)}), 503
53
+
54
+
55
+ @app.route('/tools')
56
+ def tools():
57
+ # بعض خوادم MCP تكشف endpoints أخرى؛ نحاول قراءة root JSON إن وُجد
58
+ try:
59
+ r = requests.get(f"http://127.0.0.1:{MCP_PORT}/", timeout=1.5)
60
+ return (r.text, r.status_code, {'Content-Type': 'text/html'})
61
+ except Exception as e:
62
+ return jsonify({'status':'down','error':str(e)}), 503
63
+
64
+
65
+ if __name__ == '__main__':
66
+ app.run(host='0.0.0.0', port=7860)