【发布时间】:2021-08-19 17:23:46
【问题描述】:
我正在使用数据框,我需要对其进行一些操作并在网页上显示一个表格。第一个有效,其余无效。我该怎么办? 更新更改路线也不起作用
@app.route('/')
def about():
return render_template("about.html", result=df.to_html(header='true'))
@app.route('/')
def problem():
data = df[['attempts', 'activity']]
data = df.groupby('activity').sum().sort_values('attempts', ascending=False)
return render_template("about.html", data=data.to_html(header='true'))
这是它的html部分
<section id="table">
<h2>table</h2>
<p class="lead" > {{result | safe}}</p>
</section>
<section id="problems">
<h2>problems</h2>
<p class="lead" >{{data | safe}}</p>
</section>
【问题讨论】:
-
两个端点都指向同一个 url
@app.route('/') -
我应该在那里写什么?这是一个单页网站,您可以在其中按下按钮并滚动到该部分。写 @app.route('/problems') 什么都不做
标签: python html pandas dataframe flask