flask网页对excel数据的显示

问题遇到的现象和发生背景

flask,将输入的内容和excel中的值进行对比,相同的将值输出。

现在想要实现打开网页,就能直接显示所有的数据,点击搜索再显示搜索内容和center标签内字体居中

用代码块功能插入代码,请勿粘贴截图
app = flask.Flask(__name__)
@app.route("/query", methods=["GET", "POST"])

def query_info():
    df = pd.read_excel('客户代码.xlsx')
    medal_data = pd.DataFrame()
    customerCode = request.form.get("customerCode", "")
    if customerCode:
        medal_data = df.query(f"客户代码 == '{customerCode}'")
    return f"""
        <html><body style="text-align:center">
        <h1>查询客户代码信息</h1>
        <form action="/query" method="post">
            客户代码:<input type="text" name="customerCode" value="{customerCode}">
            <input type="submit" name="submit" value="查询">
        </form>
        <center>%s</center>
        </body></html>
    """ %df.to_html(index=False)
app.run(host="0.0.0.0", port=14)

既然对customerCode做了判断,干脆加一个 else: 然后查询query.all()试试?