How to parse an Angular POST request in WebApp2

耗尽温柔 提交于 2019-12-03 07:04:53
dlebech

Judging from your first print, it seems that Angular is sending the data in JSON format. Webapp2 will not parse this data for you. For your particular request, you can do:

import json
d = json.loads(self.request.body)
v = d.get(key)

If you want to be able to access the POST data using self.request.POST.get(key), you probably need to submit the data as form data. See this SO answer for more information about that.

I always use self.request.get and able to get the data from GET/POST method, maybe you send the data in different format that only accessible by self.request.body?

olituks

You can try this:

 self.request.POST.get(key) # POST requests
 self.request.GET.get(key)  # GET requests
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!