3

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)
1
  • Both are okay. This is not a very specific python or appengine question, though.
    – Hans Then
    Nov 22, 2012 at 8:58

2 Answers 2

2

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)
7
  • I'm getting a 404 when I try this. (INFO 2012-11-22 10:12:18,441 dev_appserver.py:3092] "GET /update/1 HTTP/1.1" 404 -) Nov 22, 2012 at 10:13
  • See my updated answer please. I forgot that you are using webapp and not webapp2. Nov 22, 2012 at 11:17
  • Ok, so if the user is not using the latest version how would I serve the user (mobile client) with a file.zip that resides on the server? Nov 22, 2012 at 14:00
  • Supposing that you use the Blobstore, you can serve the file using Blobstore Python API. Nov 22, 2012 at 20:43
  • It's just a small zip file (max 20-30kb). Blobstore seems like overkill? How can I just refer to the zip-file in a directory? Nov 22, 2012 at 21:49
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.