save code

This commit is contained in:
Your Name
2026-03-10 07:10:36 +00:00
parent 01fa717f5f
commit 6d4d2c19b3
+11 -1
View File
@@ -32,7 +32,7 @@ logger.setLevel(logging.INFO) # 设置 logger 的级别
now = datetime.now() now = datetime.now()
# 格式化为字符串(例如:2023-10-25 14:30:45 # 格式化为字符串(例如:2023-10-25 14:30:45
date_time_str = now.strftime("%Y-%m-%d_%H:%M:%S") date_time_str = now.strftime("%Y-%m-%d_%H-%M-%S")
# 创建文件 handler # 创建文件 handler
file_handler = logging.FileHandler(f'/var/log/fuyan/change_app_{date_time_str}.log') file_handler = logging.FileHandler(f'/var/log/fuyan/change_app_{date_time_str}.log')
@@ -62,6 +62,12 @@ redis_pool = redis.ConnectionPool(
max_connections=2000 # 根据实际情况调整 max_connections=2000 # 根据实际情况调整
) )
from datetime import datetime
def log_message(msg):
"""简单的日志输出函数"""
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] {msg}")
logger.info(msg)
def get_redis_conn(): def get_redis_conn():
"""获取 Redis 连接""" """获取 Redis 连接"""
return redis.Redis(connection_pool=redis_pool) return redis.Redis(connection_pool=redis_pool)
@@ -818,6 +824,7 @@ def index():
@app.route('/do_change_cloth', methods=['POST']) @app.route('/do_change_cloth', methods=['POST'])
def do_change_cloth(): def do_change_cloth():
log_message("do_change_cloth called")
"""从 URL 下载图片""" """从 URL 下载图片"""
data = request.json data = request.json
@@ -925,6 +932,7 @@ def queueCall(data):
@app.route('/change_cloth', methods=['POST']) @app.route('/change_cloth', methods=['POST'])
def change_cloth(): def change_cloth():
log_message("change_cloth_base64 called")
"""从 URL 下载图片""" """从 URL 下载图片"""
data = request.json data = request.json
@@ -958,6 +966,8 @@ def change_cloth():
@app.route('/change_cloth_base64', methods=['POST']) @app.route('/change_cloth_base64', methods=['POST'])
def change_cloth_base64(): def change_cloth_base64():
log_message("change_cloth_base64 called")
# 获取参数 # 获取参数
data = request.get_json() data = request.get_json()
print(f"change_cloth_base64 input data:{data}") print(f"change_cloth_base64 input data:{data}")