Update server.py
Browse files
server.py
CHANGED
|
@@ -124,21 +124,14 @@ def check_api1():
|
|
| 124 |
try:
|
| 125 |
url = "http://127.0.0.1:8000/v1"
|
| 126 |
response = requests.get(url, timeout=30)
|
| 127 |
-
response.raise_for_status() # 检查请求是否成功
|
| 128 |
|
| 129 |
-
#
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
#
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
else:
|
| 137 |
-
print("SillyTavern未启动")
|
| 138 |
-
|
| 139 |
-
except ValueError: # 捕获 JSON 解码错误
|
| 140 |
-
print("返回的不是有效的 JSON 响应")
|
| 141 |
-
print("原始响应内容:", response.text) # 打印原始文本内容
|
| 142 |
|
| 143 |
except requests.exceptions.RequestException as e:
|
| 144 |
print(f"SillyTavern未启动3: {e}") # 打印具体错误信息
|
|
|
|
| 124 |
try:
|
| 125 |
url = "http://127.0.0.1:8000/v1"
|
| 126 |
response = requests.get(url, timeout=30)
|
|
|
|
| 127 |
|
| 128 |
+
# 检查响应状态码
|
| 129 |
+
if response.status_code == 403:
|
| 130 |
+
print("SillyTavern已经启动")
|
| 131 |
+
break # 接口正常,退出循环
|
| 132 |
+
|
| 133 |
+
# 如果不是 403,打印其他信息
|
| 134 |
+
print("SillyTavern未启动,状态码:", response.status_code)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
except requests.exceptions.RequestException as e:
|
| 137 |
print(f"SillyTavern未启动3: {e}") # 打印具体错误信息
|