MKE0108 commited on
Commit
0422fd7
·
verified ·
1 Parent(s): 3345877

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -1,23 +1,23 @@
1
  from fastapi import FastAPI
2
  import threading
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 == "0":
18
- # with open("Status.txt", "w") as status_file:
19
- # status_file.write("1")
20
- # os.system("python bot_main.py")
21
 
22
  @app.get("/")
23
  def greet_json():
 
1
  from fastapi import FastAPI
2
  import threading
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 == "0":
18
+ with open("Status.txt", "w") as status_file:
19
+ status_file.write("1")
20
+ os.system("python bot_main.py")
21
 
22
  @app.get("/")
23
  def greet_json():