Skip to content

Instantly share code, notes, and snippets.

@sjaensch
Created April 29, 2014 18:09
Show Gist options
  • Save sjaensch/11407830 to your computer and use it in GitHub Desktop.
Save sjaensch/11407830 to your computer and use it in GitHub Desktop.
import webapp2
from google.appengine.api import memcache
class MainHandler(webapp2.RequestHandler):
def get(self):
user_count = memcache.get('user_count')
if user_count is None:
user_count = 0
else:
self.response.write('Got user count {} from memcache.<br>'.format(user_count))
if not memcache.set('user_count', user_count + 1):
self.response.write('Could not set memcache value!<br>')
self.response.write('Hello world! You are visitor no. {}'.format(user_count + 1))
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment