为什么我不能将此问题命名为“标签 404 错误”?

问题描述 投票:0回答:1

我制作烧瓶网。如果用户点击 的链接,服务器必须从 MySQL 数据库获取数据并显示。但我有“404 未找到”。 以前工作时也用过。我不知道为什么突然出现这个问题。

enter image description here

enter image description here

我制作了测试烧瓶应用程序。我试了两次。 enter image description here enter image description here

一开始我尝试将URL地址与标签连接起来,但是出现了和main.py(原文件)一样的问题,我以为是路由路径的问题,于是就进入路由路径进行测试。 py 使用表单标签。但我一直收到 404 错误。

html mysql flask http-status-code-404
1个回答
0
投票

测试.py

from flask import Flask, render_template, request, redirect, url_for
app = Flask(__name__)

@app.route('/', methods=['GET','POST'])
def home():
 return render_template('test.html')


'''
@app.route('/index', methods=['GET','POST'])
def index():
     return render_template('index.html')
'''


if __name__ == '__main__':
   app.run(host='0.0.0.0', debug=True,port=8080)

测试.html

<a href="index.html">test button </a>

<!--
<form action="/index" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>
-->

当我按下测试按钮时,我想显示index.html,但出现404错误。

© www.soinside.com 2019 - 2024. All rights reserved.