Tuesday 15 January 2013

Sending a URL in a GET request to a Python server on Google App Engine -



Sending a URL in a GET request to a Python server on Google App Engine -

i have written simple server in python on google apps engine. want able send command via request, such "http://myserver.appspot.com/?do=http://webpage.com/?secondary=parameter"

this not work, secondary parameter gets interpreted separately , sent app well. help?

the url http://myserver.appspot.com/?do=http://webpage.com/?secondary=parameter uncorrectly formed. perhaps can urlencode string info , send it

from urllib import urlencode info = {"do": "http://webpage.com/?secondary=parameter"} encoded_data = urlencode(data) url = "http://myserver.appspot.com/?" + encoded_data

gives output

>>> print url http://myserver.appspot.com/?do=http%3a%2f%2fwebpage.com%2f%3fsecondary%3dparameter

alternatively, if using python requests module, can do

import requests payload = {"do": "http://webpage.com/?secondary=parameter"} r = requests.get("http://myserver.appspot.com/", params=payload)

which gives output

>>> print r.url u'http://myserver.appspot.com/?do=http%3a%2f%2fwebpage.com%2f%3fsecondary%3dparameter'

python google-app-engine parameters server get-request

No comments:

Post a Comment