def get(self): result_hash = {"errors": []} word_name = self.request.get('word') if not word_name: result_hash['errors'].append('word is empty') result = simplejson.dumps(result_hash, ensure_ascii=False) else: result = memcache.get("word-" + word_name) if not result: logging.info("cache not hit(%s)" % (word_name)) word = Word.get_by_name(word_name) if word: result_hash['word'] = word.to_hash() else: result_hash['errors'].append('word not found') result = simplejson.dumps(result_hash, ensure_ascii=False) memcache.set("word-" + word_name, result) self.response.content_type = "application/json" self.response.out.write(result) return