最近一直在开发 appengine 应用程序。我想解析对应用程序的请求中包含的 json 数据。如何使用 requesthandler 类的 request 对象来实现这一点?
下面是一段代码,显示我想要实现的目标:
import cgi
import webapp2
import datamethods
from google.appengine.ext.webapp.util import run_wsgi_app
class adduser(webapp2.RequestHandler):
def get(self):
# Get the phone number from json data in request.
userphone = self.request.get("phone")
# Get the name from json data in request.
name = self.request.get("name")
app = webapp2.WSGIApplication([
('/adduser', adduser),
('/sign', updatestatus),
('/login',login)
], debug=True)
def main():
run_wsgi_app(app)
if __name__ == "__main__":
main()