Reputation: 11064
In Python flask, I created a view using flask.views.MethodView that works if I do not send a form. But if I send a form with xml.send(form) it hangs.
JavaScript call:
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);
}
Python script:
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'))
I believe the issue is now between nginx and uwsgi.
Output from uwsgi:
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 16582)
spawned uWSGI worker 1 (pid: 16587, cores: 2)
spawned uWSGI worker 2 (pid: 16589, cores: 2)
spawned uWSGI worker 3 (pid: 16591, cores: 2)
spawned uWSGI worker 4 (pid: 16593, cores: 2)
[pid: 16591|app: 0|req: 1/1] 10.5.46.20 () {48 vars in 884 bytes} [Sat Sep 21 18:02:25 2013] POST /site/myapp/bob => generated 11 bytes in 5 msecs (HTTP/1.1 200) 2 headers in 79 bytes (1 switches on core 0)
nginx config:
server {
listen 22.22.22.22;
access_log /var/log/nginx/localhost.access_log main;
error_log /var/log/nginx/localhost.error_log info;
location / {
root /var/www/dude;
}
location /site/ {
try_files $uri @uwsgi;
}
location @uwsgi {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3031;
}
}
uwsgi config:
one@chat-dash:~$ cat /etc/uwsgi.d/myapp.ini
[uwsgi]
socket = 127.0.0.1:3031
uid = web
gid = web
plugins = python
chdir = /site
module = myapp
callable = app
pythonpath = /python
processes = 4
threads = 2
#enable-threads = true
#daemonize = /var/log/uwsgi/myapp.log
one@chat-dash:~$
Upvotes: 0
Views: 688
Reputation: 599470
Nothing is hanging here. Flash is correctly returning your response. However your JavaScript is not seeing it, because you are calling send
before defining the callback, which is the wrong way round.
Upvotes: 1