這是一個(gè)用于Python添加和刪除任務(wù)的網(wǎng)絡(luò)應(yīng)用程序。這是add_tasks函數(shù):@app.route("/add", methods=["GET", "POST"])@login_requireddef add(): if request.method == "POST": add = request.form.get("add") quantity = request.form.get("quantity") if not add: return apology("Please add an item") db.execute("INSERT INTO history (add, quantity, user_id) VALUES (:add, :quantity, :user_id);", add=add, quantity=quantity, user_id=session["user_id"]) return redirect("/") else: return render_template("add.html")然后我的刪除功能僅將存儲(chǔ)的項(xiàng)目從SQL數(shù)據(jù)庫(kù)中取出SELECT,以便刪除它們。@app.route("/delete", methods=["GET", "POST"])@login_requireddef delete(): if request.method == "POST": db.execute("DELETE FROM history (add, quantity, user_id) VALUES (:add, :quantity, :user_id);", add=add, quantity=0, user_id=session["user_id"]) else: rows = db.execute("SELECT add FROM history WHERE user_id=:user_id GROUP BY add", user_id=session["user_id"]) return render_template("delete.html", add=[row["add"] for row in rows])此刪除功能會(huì)導(dǎo)致內(nèi)部服務(wù)器錯(cuò)誤。這有什么問(wèn)題嗎?
使用Python通過(guò)html形式刪除存儲(chǔ)在SQL數(shù)據(jù)庫(kù)中的任務(wù)
料青山看我應(yīng)如是
2023-09-19 15:27:22