【发布时间】:2020-07-09 13:22:05
【问题描述】:
我在我的烧瓶应用程序中指定了一个变量,当模板被渲染时,该变量应该会显示出来。但是,变量本身并没有显示出来,而是在它的位置上显示“{{variable}}”。我该如何解决这个问题。
predictions = linear.predict(x_test)
for x in range(len(predictions)):
print(predictions[x],x_test[x], y_test[x]) #i got rid of 'y_test[x]
output = predictions[x]
p = Flask(__name__)
Bootstrap(app)
@app.route('/')
def math():
#return(y)
return render_template('index.html', variable = output)
if __name__ == "__main__":
app.run(debug = True)
这是我的索引:
<section id="services" class="bg-light">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto">
<h2>Here is the prediction for Tesla stock price</h2>
<p class="lead">Stock prediction: {{variable}}</p>
</div>
</div>
</div>
这里是实时网站:https://amanpuranik.github.io/stock2/ 这里是 github 仓库:https://github.com/amanpuranik/stock2
任何帮助将不胜感激,谢谢。
【问题讨论】:
标签: python variables github flask