I trying using Brython with Ajax imported to test ajax.post. When I do, I get the error "TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement." in my server console and the error "Failed to load resource: the server responded with a status of 500 (INTERNAL SERVER ERROR)" in the developer webpage console. My code is:
@app.route("/test", methods=["POST", "GET"])
def testing():
if request.method == "POST":
print(request.args.get("test", 0, type=str))
else:
return render_template("test.html")
and
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Testing</title>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.8.9/brython.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.8.9/brython_stdlib.js"></script>
<body onload="brython()">
<script type="text/python">
from browser import ajax
ajax.post(url="http://localhost:5000/test", data={"test": "work pls"})
</script>
</body>
</html>
How do I prevent these errors from happening and have a successful ajax post?
Edit: Fixed errors but now it is not printing the right thing