Reputation: 1276
I want to get some data from app writen in django, using kivy, django server is on 127.0.0.1:8000. I cant see any messages and the result is None, my request script is
from kivy.network.urlrequest import UrlRequest
import urllib
def success(req, result):
print 'ok'
def fail(req, result):
print 'fail'
params = urllib.urlencode({'@number': 12524, '@type': 'issue',
'@action': 'show'})
headers = {'Content-type': 'application/x-www-form-urlencoded',
'Accept': 'text/plain'}
UrlRequest('http://127.0.0.1:8000', on_success=success, on_failure=fail, on_error=fail, req_body=params, req_headers=headers)
Upvotes: 2
Views: 2937
Reputation: 368894
If you run the code not in event loop, it does not work.
To run it without GUI event loop, use UrlRequest.wait
method:
...
req = UrlRequest('http://daum.net', on_success=success, on_failure=fail,
on_error=fail, req_body=params, req_headers=headers)
req.wait()
Upvotes: 4