|
@@ -8,6 +8,7 @@ from flask import Flask, request
|
|
|
from log import Log
|
|
|
from config import set_config
|
|
|
from words_func import get_words, update_wechat_score_data
|
|
|
+from update_common_words import add_words2mysql
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
log_ = Log()
|
|
@@ -60,5 +61,33 @@ def update_wechat_score():
|
|
|
return json.dumps(result)
|
|
|
|
|
|
|
|
|
+# 更新飞书指定表格中的数据到热点词库
|
|
|
+@app.route('/hot/word/updateWords', methods=['GET', 'POST'])
|
|
|
+def update_words():
|
|
|
+ try:
|
|
|
+ start_time = time.time()
|
|
|
+ request_data = json.loads(request.get_data())
|
|
|
+ sheet_name = request_data.get('sheet_name')
|
|
|
+ source = request_data.get('source')
|
|
|
+ if sheet_name is not None and source is not None:
|
|
|
+ add_words2mysql(sheet_name=sheet_name, source=source)
|
|
|
+ result = {'code': 200, 'message': 'success'}
|
|
|
+ else:
|
|
|
+ log_.error(f"sheet_name = {sheet_name}, source = {source}")
|
|
|
+ result = {'code': -1, 'message': 'fail'}
|
|
|
+ log_message = {
|
|
|
+ 'requestUri': '/hot/word/updateWords',
|
|
|
+ 'logTimestamp': int(time.time() * 1000),
|
|
|
+ 'result': result,
|
|
|
+ 'executeTime': (time.time() - start_time) * 1000
|
|
|
+ }
|
|
|
+ log_.info(log_message)
|
|
|
+ return json.dumps(result)
|
|
|
+ except Exception as e:
|
|
|
+ log_.error(traceback.format_exc())
|
|
|
+ result = {'code': -1, 'message': 'fail'}
|
|
|
+ return json.dumps(result)
|
|
|
+
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
app.run()
|