flask and html connection
生活随笔
收集整理的这篇文章主要介绍了
flask and html connection
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
python
from flask import Flask, render_template from eas_prediction import PredictClient from eas_prediction import StringRequestapp = 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>总结
以上是生活随笔为你收集整理的flask and html connection的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: ways to change your
- 下一篇: school‘s movie demon