微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

flask and html connection

python

from flask import Flask, render_template
from eas_prediction import PredictClient
from eas_prediction import StringRequest

app = Flask('testapp')

@app.route('/')
def index():
    #下面的client = PredictClient()入参源于公网调用的访问地址。
    client = PredictClient('http://1875193938847529.cn-shanghai.pai-eas.aliyuncs.com','dequn_teng_fyp')
    #Token可以在公网地址调用信息中获取,详情请参见通用公网调用部分。
    client.set_token('OTMwNmEwNmFkYjM2Y2RlMjAzM2RkMzc3NWQ0Mzc2OGMxZTRiNzM3Zg==')
    client.init()
    #输入请求需要根据模型进行构造,此处仅以字符串作为输入输出的程序为例。
    request = StringRequest('[{"item_buy_rate":0,"user_buy_rate":0}]')
    for x in range(0, 1):
        resp = client.predict(request)

    return render_template('index.html', variable=resp)
if __name__ == '__main__':

    app.run()


HTML


<html>
<body>
    <p>Here is my variable: {{ variable }}</p>
</body>
</html>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐