MKE0108 commited on
Commit
a78369a
·
verified ·
1 Parent(s): e2cb6c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -3,7 +3,20 @@ import threading
3
  app = FastAPI()
4
  def bot_run():
5
  import os
6
- os.system("python bot_main.py")
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  @app.get("/")
8
  def greet_json():
9
  threading.Thread(target=bot_run).start()
 
3
  app = FastAPI()
4
  def bot_run():
5
  import os
6
+
7
+ # 檢查 Status.txt 是否存在,如果不存在則創建並設置初始值為 0
8
+ if not os.path.exists("Status.txt"):
9
+ with open("Status.txt", "w") as status_file:
10
+ status_file.write("0")
11
+
12
+ # 讀取 Status.txt 的值
13
+ with open("Status.txt", "r") as status_file:
14
+ status = status_file.read().strip()
15
+
16
+ # 如果 Status.txt 的值是 "1",則運行 bot_main.py
17
+ if status == "1":
18
+ os.system("python bot_main.py")
19
+
20
  @app.get("/")
21
  def greet_json():
22
  threading.Thread(target=bot_run).start()