flask and html connection
生活随笔
收集整理的這篇文章主要介紹了
flask and html connection
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
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()入?yún)⒃从诠W(wǎng)調(diào)用的訪(fǎng)問(wèn)地址。client = PredictClient('http://1875193938847529.cn-shanghai.pai-eas.aliyuncs.com','dequn_teng_fyp')#Token可以在公網(wǎng)地址調(diào)用信息中獲取,詳情請(qǐng)參見(jiàn)通用公網(wǎng)調(diào)用部分。client.set_token('OTMwNmEwNmFkYjM2Y2RlMjAzM2RkMzc3NWQ0Mzc2OGMxZTRiNzM3Zg==')client.init()#輸入請(qǐng)求需要根據(jù)模型進(jìn)行構(gòu)造,此處僅以字符串作為輸入輸出的程序?yàn)槔equest = 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>總結(jié)
以上是生活随笔為你收集整理的flask and html connection的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: ways to change your
- 下一篇: school‘s movie demon