Spaces:
Paused
Paused
| # app.py | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Sequential Thinking MCP - Status</title> | |
| <meta name="viewport" content="width=device-width,initial-scale=1"> | |
| <style> | |
| body { font-family: Inter, Arial, sans-serif; background:#0f172a; color:#e6eef8; display:flex;align-items:center;justify-content:center;min-height:100vh; } | |
| .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); } | |
| a { color: #60a5fa } | |
| pre { background: #071029; padding:12px; border-radius:8px; overflow:auto } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="card"> | |
| <h2>Sequential Thinking MCP Server</h2> | |
| <p>حالة الخادم: <strong>{{status}}</strong></p> | |
| <p>عنوان الخادم الداخلي: <code>http://127.0.0.1:{{mcp_port}}</code></p> | |
| <p>روابط مفيدة:</p> | |
| <ul> | |
| <li><a href="/health" target="_blank">/health</a> — تحقق من استجابة MCP server</li> | |
| <li><a href="/tools" target="_blank">/tools</a> — وصف الأدوات المكتشفة (إن وُجدت)</li> | |
| </ul> | |
| <hr> | |
| <h4>ملاحظات التشغيل</h4> | |
| <pre>لتشغيل محليًا: | |
| docker build -t hf-seqthink . | |
| docker run -p 7860:7860 -p 8080:8080 hf-seqthink | |
| </pre> | |
| </div> | |
| </body> | |
| </html> | |
| """ | |
| @app.route('/') | |
| def index(): | |
| try: | |
| r = requests.get(f"http://127.0.0.1:{MCP_PORT}/health", timeout=1.5) | |
| status = 'UP' if r.status_code == 200 else f'DEGRADED ({r.status_code})' | |
| except Exception as e: | |
| status = f'DOWN ({e})' | |
| return render_template_string(HTML, status=status, mcp_port=MCP_PORT) | |
| @app.route('/health') | |
| def health(): | |
| try: | |
| r = requests.get(f"http://127.0.0.1:{MCP_PORT}/health", timeout=1.5) | |
| return (r.text, r.status_code, {'Content-Type': 'text/plain'}) | |
| except Exception as e: | |
| return jsonify({'status':'down','error':str(e)}), 503 | |
| @app.route('/tools') | |
| def tools(): | |
| # بعض خوادم MCP تكشف endpoints أخرى؛ نحاول قراءة root JSON إن وُجد | |
| try: | |
| r = requests.get(f"http://127.0.0.1:{MCP_PORT}/", timeout=1.5) | |
| return (r.text, r.status_code, {'Content-Type': 'text/html'}) | |
| except Exception as e: | |
| return jsonify({'status':'down','error':str(e)}), 503 | |
| if __name__ == '__main__': | |
| app.run(host='0.0.0.0', port=7860) |