Google App Engine Python

编程入门 行业动态 更新时间:2024-10-27 07:24:30
Google App Engine Python - 简单的REST处理程序(Google App Engine Python - Simple REST handler)

我有一个场景,客户端(移动应用程序)会向我的GAE网站发送更新查询以查看该网站是否有更新版本的资源,如果有,它将返回此资源(zip文件),否则它只会返回“所有最新”的json响应(或者可能是未修改的304 HTTP响应代码)

REST URL应该如何显示(来自移动应用程序)?

www.example.com/update?version=(client_version)

要么

www.example.com/update_client_version

感谢我能得到的任何帮助。

到目前为止我所拥有的是......但是当我做http://localhost:8080/update/1时我出于某种原因得到404

INFO 2012-11-22 10:12:18,441 dev_appserver.py:3092] "GET /holidays/1 HTTP/1.1" 404 -

class UpdateHandler(webapp2.RequestHandler): def get(self, version): latestVersion == 1 if version == latestVersion: self.response.write('You are using latest version') else: self.response.write('You are not using latest version') app = webapp2.WSGIApplication([('/update/(.*)', UpdateHandler)], debug=True)

I have a scenario where a client (mobile app) would send an update query to my GAE website to see if the website has a newer version of a resource and if it does it would return this resource (zip-file) otherwise it would just return a json response "all up to date" (or perhaps a Not Modified 304 HTTP response code)

How should the REST URL look (coming from the mobile app)?

www.example.com/update?version=(client_version)

OR

www.example.com/update_client_version

Thankful for any help I can get.

What I have so far is... but I'm getting a 404 for some reason when doing http://localhost:8080/update/1

INFO 2012-11-22 10:12:18,441 dev_appserver.py:3092] "GET /holidays/1 HTTP/1.1" 404 -

class UpdateHandler(webapp2.RequestHandler): def get(self, version): latestVersion == 1 if version == latestVersion: self.response.write('You are using latest version') else: self.response.write('You are not using latest version') app = webapp2.WSGIApplication([('/update/(.*)', UpdateHandler)], debug=True)

最满意答案

我会采用以下方法:

www.example.com/update/client_version

您的代码应如下所示:

import webapp2 class UpdateHandler(webapp2.RequestHandler): def get(self, version): # Do something for version app = webapp2.WSGIApplication( [(r'/update/(\d+)', UpdateHandler)], debug=True)

I would go with the following approach:

www.example.com/update/client_version

Your code should look like this:

import webapp2 class UpdateHandler(webapp2.RequestHandler): def get(self, version): # Do something for version app = webapp2.WSGIApplication( [(r'/update/(\d+)', UpdateHandler)], debug=True)

更多推荐

本文发布于:2023-07-31 00:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1340401.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:App   Google   Python   Engine

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!