#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/5/12 0012 18:46
# @Author  : guopeng
# @File    : talking_name.py
# @Software: PyCharm Community Edition

import requests
import json
from flask import request

def ProductService(json_info):
    print(json_info)
    # json_info = eval(json_info)
    url = 'https://entprofile.gongsibao.com/api/talkingName'  # 获取信息接口
    headers = {"Content-Type":"application/json","ak":"YLc6GsgLtuRGaVA5Om848x18NxLtHlyA"}
    # companyname = {"companyname":companyname}# 接口访问参数
    companyInfo = requests.post(url,data=json.dumps(json_info),headers=headers)  # 访问接口返回的信息
    # resultinfo=json.loads(companyInfo.text)
    print(companyInfo.text)
    return companyInfo.text

# 服务器接口API
def talkingName_new(server):
    @server.route('/api/talkingNameGai', methods=['POST'])
    def SingleLogoApi_re():
        try:
            recommend_product = request.get_json().get("recommend_product")
            datas = ProductService({"recommend_product": recommend_product})
            data1 = json.loads(datas)
            data_talk = data1["data"]
            mq = data_talk[2]
            list1 = []
            for i in mq.split('\n'):
                list1.append(i)
            print(list1)
            return  json.dumps({"status": 0, "msg": "成功", "data": list1}, ensure_ascii=False)

        except:
            return json.dumps({"status": -1, "msg":"调用服务出错","data": {}}, ensure_ascii=False)


# if __name__ == '__main__':
#     CORS(app, supports_credentials=True)#允许跨域
#     # app.run(host='172.16.18.2', port=15501, debug=True)
#     app.run(host='127.0.0.1', port=5000, debug=True)
