def get(self, format): # allow cross-origin requests self.response.headers["Access-Control-Allow-Origin"] = "*" self.response.headers["Access-Control-Allow-Methods"] = "GET" if format == "json": # set the type to JSON self.response.headers["Content-Type"] = "application/json" # Get the parameters, filling in default values where needed query = self.request.get("q") if not query: query = "" limit = parseInt(self.request.get("limit"), DEFAULT_QUERY_LIMIT) offset = parseInt(self.request.get("offset"), DEFAULT_QUERY_OFFSET) sortBy = self.request.get("sortby") if not sortBy: sortBy = SORT_BEST_MATCH # Get the search results extList = searchFor(query, limit, offset, sortBy) # Turn the list of Extensions into a list of dictionaries extDictList = createExtDictList(extList, self.request.host_url) # Convert the dictionaries to JSON and print it self.response.out.write(json.dumps(extDictList)) else: error404(self.response)
def get(self, page): # Get the top five extensions extlist = searchFor('',limit=4,sortBy=SORT_TOP_RATING) path = os.path.join(os.path.dirname(__file__), 'templates/head.html') self.response.out.write(template.render(path, {})) path = os.path.join(os.path.dirname(__file__), 'templates/landing.html') self.response.out.write(template.render(path, {'extlist':extlist})) path = os.path.join(os.path.dirname(__file__), 'templates/foot.html') self.response.out.write(template.render(path, {}))
def get(self,format): if format == 'json': # set the type to JSON self.response.headers['Content-Type'] = 'application/json' # Get the query query = self.request.get('q') # Get the search results extList = searchFor(query) # Turn the list of Extensions into a list of dictionaries extDictList = createExtDictList(extList,self.request.host_url) # Convert the dictionaries to JSON and print it self.response.out.write(json.dumps(extDictList)) else: error404(self.response)