I've been banging my head against this method in Flask for some time, and while it seems I'm making progress now, I've just happened upon something that baffles me to no end. Here is the method I'm calling:
@app.route('/facedata/<slug>', methods=["POST"])
def facedata(slug):
if request.method == "POST":
try:
post = Post.objects.get_or_404(slug=slug)
data = [float(item) for item in request.form.getlist('emotions[]')]
post.face_data.append(data)
post.save()
except:
traceback.print_exc(file=sys.stdout)
For a long time I was getting errors in here that would then be caught in the heroku logs. Currently there are no errors, implying that it doesn't reach the except loop, but even worse, there are still 500 errors. Specifically the 500 errors I get are:
heroku[router]: at=info method=POST path=/facedata/StripedVuitton host=cryptic-mountain-6390.herokuapp.com fwd="18.111.90.180" dyno=web.2 connect=4ms service=39ms status=500 bytes=291
I'm sending these POST
requests via AJAX in this method:
var slug = document.getElementById("hidden-slug").getAttribute("value");
data = {emotions: lRes};
$.ajax({
type: "POST",
data: data,
url: document.location.origin + "/facedata/" + slug,
success: function(){
console.log("Success!");
}
});
Quite honestly I just don't know how to continue debugging this problem. It doesn't make a lot of sense to me to be getting a traceback without an exception, but maybe I'm just being naive.
I'm using mongoengine on top of MongoHQ on Heroku if that's relevant.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…