Update app.py
Browse files
app.py
CHANGED
@@ -104,8 +104,7 @@ def save_data_to_webdav():
|
|
104 |
|
105 |
response = requests.put(f"{WEBDAV_URL}/tg_bot/bot_data.json",
|
106 |
data=json_data,
|
107 |
-
auth=HTTPBasicAuth(WEBDAV_USERNAME, WEBDAV_PASSWORD)
|
108 |
-
timeout=30)
|
109 |
|
110 |
if response.status_code in [200, 201, 204]:
|
111 |
print(f"数据已成功保存到WebDAV: {datetime.now()}")
|
@@ -120,8 +119,7 @@ def load_data_from_webdav():
|
|
120 |
print(f"开始从WebDAV加载数据: {datetime.now()}")
|
121 |
try:
|
122 |
response = requests.get(f"{WEBDAV_URL}/tg_bot/bot_data.json",
|
123 |
-
auth=HTTPBasicAuth(WEBDAV_USERNAME, WEBDAV_PASSWORD)
|
124 |
-
timeout=30)
|
125 |
|
126 |
if response.status_code == 200:
|
127 |
data = json.loads(response.text)
|
@@ -144,7 +142,7 @@ def load_data_from_webdav():
|
|
144 |
def periodic_save():
|
145 |
print("定期保存线程已启动")
|
146 |
while True:
|
147 |
-
time.sleep(
|
148 |
save_data_to_webdav()
|
149 |
|
150 |
load_data_from_webdav()
|
|
|
104 |
|
105 |
response = requests.put(f"{WEBDAV_URL}/tg_bot/bot_data.json",
|
106 |
data=json_data,
|
107 |
+
auth=HTTPBasicAuth(WEBDAV_USERNAME, WEBDAV_PASSWORD))
|
|
|
108 |
|
109 |
if response.status_code in [200, 201, 204]:
|
110 |
print(f"数据已成功保存到WebDAV: {datetime.now()}")
|
|
|
119 |
print(f"开始从WebDAV加载数据: {datetime.now()}")
|
120 |
try:
|
121 |
response = requests.get(f"{WEBDAV_URL}/tg_bot/bot_data.json",
|
122 |
+
auth=HTTPBasicAuth(WEBDAV_USERNAME, WEBDAV_PASSWORD))
|
|
|
123 |
|
124 |
if response.status_code == 200:
|
125 |
data = json.loads(response.text)
|
|
|
142 |
def periodic_save():
|
143 |
print("定期保存线程已启动")
|
144 |
while True:
|
145 |
+
time.sleep(10)
|
146 |
save_data_to_webdav()
|
147 |
|
148 |
load_data_from_webdav()
|