|
@@ -1,6 +1,7 @@
|
|
import os
|
|
import os
|
|
from flask import Flask, request
|
|
from flask import Flask, request
|
|
from MoneyRecord import MoneyRecord
|
|
from MoneyRecord import MoneyRecord
|
|
|
|
+from task import TikTask
|
|
from user import User
|
|
from user import User
|
|
import logging
|
|
import logging
|
|
from logging.handlers import TimedRotatingFileHandler
|
|
from logging.handlers import TimedRotatingFileHandler
|
|
@@ -28,6 +29,12 @@ def money_action(action):
|
|
return r
|
|
return r
|
|
|
|
|
|
|
|
|
|
|
|
+@app.route('/task/<action>', methods=['POST'])
|
|
|
|
+def tik_task_action(action):
|
|
|
|
+ data = request.get_json()
|
|
|
|
+ r = TikTask(action=action, data=data, logger=logger).tik_task_router()
|
|
|
|
+ return r
|
|
|
|
+
|
|
class CustomLogger:
|
|
class CustomLogger:
|
|
def __init__(self, log_file):
|
|
def __init__(self, log_file):
|
|
self.log_file = log_file
|
|
self.log_file = log_file
|
|
@@ -64,6 +71,8 @@ day = current_date.day
|
|
# 将年月日格式化为字符串
|
|
# 将年月日格式化为字符串
|
|
formatted_date = current_date.strftime("%Y-%m-%d")
|
|
formatted_date = current_date.strftime("%Y-%m-%d")
|
|
logger = CustomLogger(f'{os.path.dirname(__file__)}/logs/{formatted_date}.log')
|
|
logger = CustomLogger(f'{os.path.dirname(__file__)}/logs/{formatted_date}.log')
|
|
|
|
+
|
|
|
|
+
|
|
# logger = CustomLogger(f'/Users/jasonphd/Desktop/gogs/JasonPhdWork/server/flaskProject/logs{formatted_date}.log')
|
|
# logger = CustomLogger(f'/Users/jasonphd/Desktop/gogs/JasonPhdWork/server/flaskProject/logs{formatted_date}.log')
|
|
# logger = CustomLogger(f'/root/api_server/JasonPhdWork/app/logs/{formatted_date}.log')
|
|
# logger = CustomLogger(f'/root/api_server/JasonPhdWork/app/logs/{formatted_date}.log')
|
|
|
|
|
|
@@ -72,9 +81,9 @@ logger = CustomLogger(f'{os.path.dirname(__file__)}/logs/{formatted_date}.log')
|
|
@app.before_request
|
|
@app.before_request
|
|
def log_request_info():
|
|
def log_request_info():
|
|
data = request.get_json()
|
|
data = request.get_json()
|
|
- data["intime"] = int (time.time())
|
|
|
|
|
|
+ data["intime"] = int(time.time())
|
|
logger.log(f"url:{request.url} params:{data} method:{request.method} ip:{request.remote_addr}")
|
|
logger.log(f"url:{request.url} params:{data} method:{request.method} ip:{request.remote_addr}")
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
- app.run(host='0.0.0.0',port=5005)
|
|
|
|
|
|
+ app.run(host='0.0.0.0', port=5005)
|