![](/img/trans.png)
[英]Use a CSV file to populate a webpage that display the latest weather using flask?
[英]Printing a CSV table on a webpage using flask
因此,我嘗試使用pandas創建數據框,最后將其轉換為html文件,然后將數據放入dataset.html中。 因此,我將dataset.html文件留為空白。 但是當我運行它時,“ /數據集”頁面為空。 我該如何解決?
from flask import Flask, render_template
import pandas as pd
app = Flask(__name__)
@app.route('/')
def home_page():
return render_template("home.html")
@app.route('/dataset')
def another_page():
table = pd.DataFrame.from_csv("Soccer.csv")
return render_template("dataset.html", data=table.to_html)
if __name__ == '__main__':
app.run(debug=True, use_reloader=True)
您應該具有data=table.to_html()
to_html()
是一個函數
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.