Qilan2 commited on
Commit
0e1616a
·
verified ·
1 Parent(s): 2a49194

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +7 -14
server.py CHANGED
@@ -285,21 +285,16 @@ def check_api1():
285
  Service_status = False
286
  # 第二次检查接口状态
287
  while True:
288
- url = f"{st_url}/v1" # 确保这个 URL 是正确的
289
-
290
  try:
291
  response = requests_retry_session().get(url, timeout=30)
292
  response.raise_for_status() # 检查响应状态
293
-
294
- # 检查返回的状态码
295
- if response.status_code == 403:
296
- print("SillyTavern还在启动")
297
-
298
-
299
- # 尝试解析 JSON 响应
300
- response_json = response.json()
301
-
302
- # 检查返回信息是否包含特定内容
303
  if "detail" in response_json and response_json["detail"] in ("Method Not Allowed", "Not Found"):
304
  print("接口正常1")
305
  else:
@@ -321,8 +316,6 @@ def check_api1():
321
  # threading.Thread(target=sync, daemon=True).start()
322
  # thread_started = True # 设置标志为 True,表示线程已经启动过了
323
  # break
324
-
325
- print("接口正常3")
326
 
327
  except requests.exceptions.ConnectionError as e:
328
  print(f"接口异常1: {e}")
 
285
  Service_status = False
286
  # 第二次检查接口状态
287
  while True:
288
+ url = f"{st_url}/v1" # 确保这个 URL 是正确的
 
289
  try:
290
  response = requests_retry_session().get(url, timeout=30)
291
  response.raise_for_status() # 检查响应状态
292
+ # 获取响应内容
293
+ response_text = response.text # 获取 HTML 内容
294
+ # 模糊查找注册账号相关信息
295
+ if "注册" in response_text or "账号" in response_text:
296
+ print("检测到注册账号相关信息,结束检测")
297
+ break # 跳出循环
 
 
 
 
298
  if "detail" in response_json and response_json["detail"] in ("Method Not Allowed", "Not Found"):
299
  print("接口正常1")
300
  else:
 
316
  # threading.Thread(target=sync, daemon=True).start()
317
  # thread_started = True # 设置标志为 True,表示线程已经启动过了
318
  # break
 
 
319
 
320
  except requests.exceptions.ConnectionError as e:
321
  print(f"接口异常1: {e}")