Reputation: 107
I have written a very simple server in Python on Google Apps engine. I want to be able to send it a command via a GET request, such as "http://myserver.appspot.com/?do=http://webpage.com/?secondary=parameter"
This does not work, as the secondary parameter gets interpreted separately and sent to my app as well. Any help?
Upvotes: 1
Views: 276
Reputation: 76887
The url http://myserver.appspot.com/?do=http://webpage.com/?secondary=parameter
is uncorrectly formed. Perhaps you can urlencode
the string data and then send it
from urllib import urlencode
data = {"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 you are using python requests
module, you 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'
Upvotes: 1