|
@@ -11,13 +11,13 @@ monkey.patch_all()
|
|
|
from flask import Flask, request
|
|
|
from log import Log
|
|
|
from config import set_config
|
|
|
-from ad_predict import get_ad_idea_id_with_thompson
|
|
|
+from ad_predict import get_creative_id_with_thompson
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
log_ = Log()
|
|
|
config_ = set_config()
|
|
|
|
|
|
-log_.info(f"server start...")
|
|
|
+
|
|
|
|
|
|
|
|
|
@app.route('/healthcheck')
|
|
@@ -25,17 +25,17 @@ def health_check():
|
|
|
return 'ok!'
|
|
|
|
|
|
|
|
|
-@app.route('/ad/predict/getAdIdeaId', methods=['GET', 'POST'])
|
|
|
-def get_ad_idea_id():
|
|
|
+@app.route('/ad/predict/getCreativeId', methods=['GET', 'POST'])
|
|
|
+def get_creative_id():
|
|
|
start_time = time.time()
|
|
|
try:
|
|
|
request_data = json.loads(request.get_data())
|
|
|
mid = request_data.get('mid')
|
|
|
- ad_idea_id_list = request_data.get('adIdeaIdList')
|
|
|
- thompson_result = get_ad_idea_id_with_thompson(mid=mid, ad_idea_id_list=ad_idea_id_list)
|
|
|
- result = {'code': 200, 'message': 'success', 'data': {'mid': mid, 'adIdeaId': thompson_result['ad_idea_id']}}
|
|
|
+ creative_id_list = request_data.get('creativeIdList')
|
|
|
+ thompson_result = get_creative_id_with_thompson(mid=mid, creative_id_list=creative_id_list)
|
|
|
+ result = {'code': 200, 'message': 'success', 'data': {'mid': mid, 'creativeId': thompson_result['creative_id']}}
|
|
|
log_message = {
|
|
|
- 'requestUri': '/ad/predict/getAdIdeaId',
|
|
|
+ 'requestUri': '/ad/predict/getCreativeId',
|
|
|
'logTimestamp': int(time.time() * 1000),
|
|
|
'requestData': request_data,
|
|
|
'thompsonResult': thompson_result,
|