Upload 11 files
Browse files- api_solver.py +22 -0
api_solver.py
CHANGED
|
@@ -881,6 +881,28 @@ class TurnstileAPIServer:
|
|
| 881 |
|
| 882 |
|
| 883 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 884 |
@staticmethod
|
| 885 |
async def index():
|
| 886 |
"""Serve the API documentation page."""
|
|
|
|
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
+
async def health_check(self):
|
| 885 |
+
"""健康检查端点 - 用于 Hugging Face Spaces"""
|
| 886 |
+
return jsonify({
|
| 887 |
+
"status": "healthy",
|
| 888 |
+
"service": "turnstile-solver",
|
| 889 |
+
"version": "1.2b"
|
| 890 |
+
}), 200
|
| 891 |
+
|
| 892 |
+
async def readiness_check(self):
|
| 893 |
+
"""就绪检查端点 - 检查浏览器是否已初始化"""
|
| 894 |
+
if self.is_ready:
|
| 895 |
+
return jsonify({
|
| 896 |
+
"status": "ready",
|
| 897 |
+
"browser_pool_size": self.browser_pool.qsize(),
|
| 898 |
+
"message": "Service is ready to accept requests"
|
| 899 |
+
}), 200
|
| 900 |
+
else:
|
| 901 |
+
return jsonify({
|
| 902 |
+
"status": "initializing",
|
| 903 |
+
"message": "Browser pool is still initializing, please wait..."
|
| 904 |
+
}), 503
|
| 905 |
+
|
| 906 |
@staticmethod
|
| 907 |
async def index():
|
| 908 |
"""Serve the API documentation page."""
|