python - giving error the request url was not found on your server
问题描述
i am getting error 404 while running this The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again. how do i need to run the server ? please help
from flask import Flask
from flask import render_template
from flask import request
app = Flask(__name__, template_folder="templates/")
app.route("/login", method=['POST', 'GET'])
def index():
greeting = "Hello World"
if request.method == "POST":
name = request.form['name']
greet = request.form['greet']
greeting = f"{greet}, {name}"
return render_template("index.html", greeting=greeting)
else:`enter code here`
return render_template("hello_form.html")
if __name__ == "__main__":
app.run(debug=True)
解决方案
你需要更换
app.route("/login", method=['POST', 'GET'])
经过
@app.route("/login", methods=['POST', 'GET'])
编辑:还有,methods
推荐阅读
- java - 如何将一个字符串设置为另一个字符串的特定字符
- javascript - Vue路由器在第一次加载时不加载组件
- exe - 在 Windows 10 上签名的可执行代码在 Windows 7 中无法识别
- c - 将 32 位正整数转换为空终止字符串的查找表需要多少 RAM
- python - Python 3.x 字典
- r - 在 R 中保留正则表达式字符
- python - argparse:选项采用一个或两个参数
- c# - 在 Unity HoloLens 项目中读取 XML 文件:在编辑器中工作,而不是在部署的项目中
- javascript - Excel 或 Access Data 中的 HTML 动态下拉菜单
- spring - localhost:8080 上的完整身份验证错误,但 localhost:3000 上没有