【发布时间】:2021-01-30 00:25:49
【问题描述】:
我正在用 python 创建一个 Flask 应用程序,但遇到了一个问题。
我只是想知道是否说您在 index.html 上有两个按钮,它们做不同的事情
假设你有一个这样的html文件
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Site!</title>
</head>
<body>
<form action="#" method="post">
<button type="submit">Somthing1</button>
<button type="submit">Somthing2</button>
</form>
</body>
</html>
还有这样的功能
@app.route("/", methods = ["GET", "POST"])
def home():
if(request.method == "POST"):
# Solution here
return "Hello, World!"
我如何判断标记为“Somthing1”或“Something2”的按钮被按下了?
【问题讨论】:
-
我的回答对您有帮助,请采纳,以便其他人看到您的问题已解决,更容易找到正确答案。