为什么 Python Flask 抛出 HTTP 404 错误

Why does Python Flask throw a HTTP 404 error

我已经好几年没有使用 Flask 了,开始一个新项目。 我收到 HTTP 404 错误。没有找到请求的URL??

索引和请求的 URL 都在模板文件夹中。 我不明白为什么会抛出 HTTP 404 错误??

感谢任何指点,谢谢。

克莱夫

我在 routes.py 中有一个代码片段。

@app.route('/service_response', methods=['GET','POST'])
def service_response():
  servicesql = "SELECT * FROM DASHBOARD_SERVICE_RESPONSE"
  data = list(conn.execute(servicesql))
      
  return render_template('service_response.html', service_response=servicesql)

在index.html我有:

<div class="form chartdisplay" >
    <div class="form-heading">BCC Report Period</div>   
        <br>
        <div class="form-group"; class="height-auto";>  
            <table>
                <thead>
                    <iframe src="service_response.html" width="90%" height="90%"></iframe>
                </thead>            
            </table>
        </div>
</div>

您的代码指向 src="service_response.html",而您要做的是指向 /service_response,这将呈现 'service_response.html' jinja 模板。