python - for提交后重定向到首页
问题描述
尝试在提交表单后将我的网络应用程序重定向到主页,但它只是在地址栏中提供表单的查询。例如 /form?Name=input&Location=input
脚本.py
@app.route("/")
def home():
return render_template("index.html")
@app.route("/form", methods=["POST", "GET"])
def form():
if request.method == "GET":
return render_template("form.html")
else:
return redirect(url_for("home"))
表单.html
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form >
<input type="text" name="Name">
<input type="text" name="Location">
<input type="submit" value="submit">
</form>
</body>
</html>
解决方案
推荐阅读
- three.js - AFrame/three.js 设备识别
- javascript - 如何将 ipcMain.on 调用移到 main.js 文件之外
- java - 将两个子类的对象存储在同一个 Vector/List 中
- python - Python-for循环x次,循环中包含信息
- c - 释放一个双链表
- android - Android / Google Map:位置更改重置缩放和方位
- postgresql - 使用连接索引
- swift - BigSur 下 Swift 中的 NSWorkspace.shared.openApplication 问题
- javascript - 格式化日期 netlify cms 不会改变
- python - 未找到 Web 元素,但在手动检查时出现