def get(self): # http://docs.python.org/library/json.html # http://stackoverflow.com/questions/10468553/google-app-engine-json-response-as-rest # https://developers.google.com/appengine/docs/python/tools/webapp/redirects paliword = cgi.escape(self.request.get('word')) self.response.headers['Content-Type'] = 'application/javascript' self.response.out.write("%s(%s);" % (self.request.get('callback'), json.dumps(jsonpLookup(paliword))))
def get(self): # http://docs.python.org/library/json.html # http://stackoverflow.com/questions/10468553/google-app-engine-json-response-as-rest # https://developers.google.com/appengine/docs/python/tools/webapp/redirects paliword = cgi.escape(self.request.get('word')) self.response.headers['Content-Type'] = 'application/javascript' self.response.out.write( "%s(%s);" % (self.request.get('callback'), json.dumps(jsonpLookup(paliword))))
def get(self, prefix=None, word=None): locale = getUserLocale(self.request.GET.get('locale'), self.request.headers.get('accept_language')) i18n.get_i18n().set_locale(locale) #browser = self.request.headers.get('user_agent') titleword = u'' resultDivInnerHTML = None if self.request.path.startswith('/browse'): if isValidPrefixAndWord(prefix, word, dicPrefixWordLists): if (word == None): if (prefix != None): # build prefix HTML here titleword = u'browse words with prefix ' + prefix.decode( 'utf-8') + u' - ' resultDivInnerHTML = getPrefixHTML( prefix, dicPrefixWordLists) else: # build word HTML here titleword = word.decode( 'utf-8') + u' - definition and meaning - ' resultDivInnerHTML = getWordHTML(word, jsonpLookup(word), i18n) else: self.error(404) self.response.out.write("Page Not Found!") return compiledBootstrapJS = self.request.GET.get('compiledBootstrapJS') if compiledBootstrapJS not in ['yes', 'no']: compiledBootstrapJS = None if (compiledBootstrapJS == None): if os.environ['SERVER_SOFTWARE'].startswith("Development"): compiledBootstrapJS = 'no' else: compiledBootstrapJS = 'yes' template_values = { 'titleword': titleword, 'locale': '%s~%s' % (locale, self.request.headers.get('accept_language')), 'compiledBootstrapJS': compiledBootstrapJS, 'resultDivInnerHTML': resultDivInnerHTML } template = jinja_environment.get_template('index.html') self.response.out.write(template.render(template_values))
def get(self, prefix=None, word=None): locale = getUserLocale(self.request.GET.get('locale'), self.request.headers.get('accept_language')) i18n.get_i18n().set_locale(locale) #browser = self.request.headers.get('user_agent') titleword = u'' resultDivInnerHTML = None if self.request.path.startswith('/browse'): if isValidPrefixAndWord(prefix, word, dicPrefixWordLists): if (word == None): if (prefix != None): # build prefix HTML here titleword = u'browse words with prefix ' + prefix.decode('utf-8') + u' - ' resultDivInnerHTML = getPrefixHTML(prefix, dicPrefixWordLists) else: # build word HTML here titleword = word.decode('utf-8') + u' - definition and meaning - ' resultDivInnerHTML = getWordHTML(word, jsonpLookup(word), i18n) else: self.error(404) self.response.out.write("Page Not Found!") return compiledBootstrapJS = self.request.GET.get('compiledBootstrapJS') if compiledBootstrapJS not in ['yes', 'no']: compiledBootstrapJS = None if (compiledBootstrapJS == None): if os.environ['SERVER_SOFTWARE'].startswith("Development"): compiledBootstrapJS = 'no' else: compiledBootstrapJS = 'yes' template_values = { 'titleword' : titleword, 'locale' : '%s~%s' % (locale, self.request.headers.get('accept_language')), 'compiledBootstrapJS' : compiledBootstrapJS, 'resultDivInnerHTML' : resultDivInnerHTML } template = jinja_environment.get_template('index.html') self.response.out.write(template.render(template_values))
def post(self): paliword = cgi.escape(self.request.get('word')) self.response.headers['Content-Type'] = 'application/json' self.response.out.write(json.dumps(jsonpLookup(paliword)))