liqian %!s(int64=3) %!d(string=hai) anos
pai
achega
a762808a9c
Modificáronse 1 ficheiros con 7 adicións e 2 borrados
  1. 7 2
      app.py

+ 7 - 2
app.py

@@ -1,4 +1,6 @@
 import json
+import time
+
 from flask import Flask, request
 from log import Log
 from config import set_config
@@ -22,6 +24,7 @@ def health_check():
 # 首页推荐及tab分类
 @app.route('/applet/video/homepage/recommend', methods=['GET', 'POST'])
 def homepage_recommend():
+    start_time = time.time()
     try:
         request_data = json.loads(request.get_data())
         mid = request_data.get('mid')
@@ -38,13 +41,15 @@ def homepage_recommend():
             # 推荐
             videos = video_recommend(mid=mid, uid=uid, size=size, app_type=app_type, algo_type=algo_type)
             result = {'code': 200, 'message': 'success', 'data': {'videos': videos}}
-            log_.info('result: {}'.format(result))
+            log_.info('category_id: {}, mid: {}, uid: {}, result: {}, execute time = {}ms'.format(
+                category_id, mid, uid, result, (time.time() - start_time)*1000))
             return json.dumps(result)
         elif category_id in config_.CATEGORY['other']:
             # 其他类别
             videos = get_category_videos()
             result = {'code': 200, 'message': 'success', 'data': {'videos': videos}}
-            log_.info('result: {}'.format(result))
+            log_.info('category_id: {}, mid: {}, uid: {}, result: {}, execute time = {}ms'.format(
+                category_id, mid, uid, result, (time.time() - start_time) * 1000))
             return json.dumps(result)
         else:
             log_.error('categoryId error, categoryId = {}'.format(category_id))