Sending a URL in a GET request to a Python server on Google App Engine
Question: 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?


Answer: 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`](http://docs.python-
requests.org/en/latest/user/quickstart/#passing-parameters-in-urls) 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'
    

