2014-11-11 2 views
1

나는 Google Apps 엔진에서 Python으로 매우 간단한 서버를 작성했습니다. "http://myserver.appspot.com/?do=http://webpage.com/?secondary=parameter"Google App Engine의 Python 서버에 GET 요청으로 URL 보내기

보조 매개 변수가 별도로 해석되어 내 앱으로 전송되기 때문에 작동하지 않습니다. 예를 들어 GET 요청을 통해 명령을 보낼 수 있습니다. 도움이 되었습니까?

+0

이것은 GAE에 대한 질문이 아닙니다. –

답변

1

url http://myserver.appspot.com/?do=http://webpage.com/?secondary=parameter이 올바르게 형성되지 않았습니다. 당신은 파이썬 requests 모듈을 사용하는 경우 아마도 당신은 문자열 데이터를 urlencode 수 있으며, 다음을 보내

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

가, 또는 출력

>>> print url 
http://myserver.appspot.com/?do=http%3A%2F%2Fwebpage.com%2F%3Fsecondary%3Dparameter 

을 제공합니다, 당신은

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

출력을 제공하는 할 수 있습니다

>>> print r.url 
u'http://myserver.appspot.com/?do=http%3A%2F%2Fwebpage.com%2F%3Fsecondary%3Dparameter'