欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

flask and html connection

发布时间:2025/3/18 编程问答 26 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。