I have two gae apps and want to send data between the two.
First app(localhost):
import requests
class PostHandler(Handler):
def get(self):
post_url = "https://www.example.com/api/post"
datas = lib.data_cache()
output = [data.as_dict() for data in datas]
headers = {'content-type': 'application/json'}
#self.write(output)
r = requests.post(post_url, data=json.dumps(output), headers=headers)
www.example.com:
class RetrieveHandler(Handler):
def post(self):
post_data = self.requests.POST.items()
#What should I do here? Is this correct?
I'm not getting the post_data properly. Anyone knows where I can get documentation on this in python and app engine? Any advice would be grateful. Thanks.
Using webapp2, you can extract POST request body data with a webapp2.RequestHandler instance like this
data = self.request.body
Because you are sending JSON, you probably want to parse that right away
data = json.loads(self.request.body)
Also see https://webapp-improved.appspot.com/guide/request.html#common-request-attributes for what other info you can get from the request object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With