librelist archives

« back to archive

Flask hangs when Form Submitted

Flask hangs when Form Submitted

From:
d hee
Date:
2013-09-22 @ 05:52
Hello,

I can not send a form to Flask. If I do xml.send(null), my flask script 
works with no issues. But if I do xml.send(form) it hangs and does not 
return. I am using flask-0.10.1-r1 along with uwsgi 1.4.10. Here is my 
code...if anyone could please help:

one@chat-dash:/var/www/dude/js$ cat main.js 
function jackpot() {
            var form = new FormData();
    var fname = "hello there";
    form.append("filename", fname);
    var xml = new XMLHttpRequest();
    xml.open("POST", "/site/myapp/bob", true);
    console.log("sent")
    xml.onreadystatechange = function () {
                     console.log(xml.readyState);
                     console.log(xml.status);
                      if (xml.readyState == "4" && xml.status == "200"){
                                console.log("yes");
                               console.log(xml.responseText);
                     }
    }
      xml.send(form)
  }
    


myapp.py:


import flask, flask.views
app = flask.Flask(__name__)

class View1(flask.views.MethodView):
    def get(self):
pass

    def post(self):
return "hello world"
#return str(flask.request.form('filename'))

app.add_url_rule('/site/myapp/bob', view_func=View1.as_view('bob'))