For part of CS50's survey problem from pset7, I'm supposed to redirect from a route that checks if the user has entered in all the survey's fields / appends the values to a csv file --> a route that reads the values from the file to a new form that displays all entries in a data table. For some reason I can't get rid of a syntax error when implementing return redirect("/sheet"). I've imported redirect from flask, and there's a part of the code using redirect earlier on that doesn't return an error. I have no idea what I'm doing wrong.

@app.route("/form", methods=["POST"]) def post_form(): if not request.form.get("name"): return render_template("error.html") if not request.form.get("quest"): return render_template("error.html") if not request.form.get("color"): return render_template("error.html") # write form values to new row in survey.csv with open("survey.csv", "a") as file: writer = csv.writer(file) writer.writerow((request.form.get("name"), request.form.get("quest"), request.form.get("color")) return redirect("/sheet") invalid syntax on this line?

@app.route("/sheet", methods=["GET"]) def get_sheet(): with open("registered.csv", "r") as file: reader = csv.reader(file) knights = list(reader) return render_template("tested.html", knights=knights) `


I realized I was missing a parenthesis... I'm dumb.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .