This is my code:
@app.route("/add", methods=["POST"])
def post_new_cafe():
new_cafe = Cafe(
name=request.form.get("name"),
map_url=request.form.get("map_url"),
img_url=request.form.get("img_url"),
location=request.form.get("loc"),
has_sockets=bool(request.form.get("sockets")),
has_toilet=bool(request.form.get("toilet")),
has_wifi=bool(request.form.get("wifi")),
can_take_calls=bool(request.form.get("calls")),
seats=request.form.get("seats"),
coffee_price=request.form.get("coffee_price"),
)
db.session.add(new_cafe)
db.session.commit()
return jsonify(response={"success": "Successfully added the new cafe."})
The Error I’m getting with URL http://127.0.0.1:5000/add is
Method Not Allowed
The method is not allowed for the requested URL.
What should I do to get the form to work?
New contributor
wicked00uux is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.