Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,23 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
import threading
|
| 3 |
app = FastAPI()
|
| 4 |
-
|
| 5 |
-
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 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():
|