Reputation: 11710
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)
Upvotes: 3
Views: 1558
Reputation: 3115
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)
Upvotes: 2
Reputation: 11322
If you intend to use HTTP 304, you should see if you can get the client to make a conditional GET request. E.g. add a header If-Modified-Since: Thu, 22 Nov 2012 09:24:52 GMT
.
Upvotes: 1