Exemplo n.º 1
0
class query:
    def __init__(self):
        pass

    def GET(self, path=None):

        if not path.find('/') > -1:
            web.header('Content-Type', 'text/html; charset=utf-8', unique=True)
            self.api = API()
            i = web.input()
            if "q" in i.keys():
                path = i["q"]
            if path:
                now = time.time()
                self.api.query(path, False)
                return (Template(results,
                                 default_filters=['unicode'],
                                 input_encoding='utf-8').render_unicode(
                                     numfound=self.api.numfound,
                                     records=self.api.records,
                                     elapse=now,
                                     keyword=path))
        else:
            now = time.time()
            page = int(path.split('/')[0])
            query = path.split('/')[1]
            return (simplejson.dumps())

        return 'Hello, world!'
Exemplo n.º 2
0
class query:
    def __init__(self):
        pass

    def GET(self, path=None):
        web.header('Content-Type', 'text/html; charset=utf-8', unique=True)
        self.api = API()
        i = web.input()
        if "q" in i.keys():
            path = i["q"]
        if not path:
            path = "Random OR Image OR Explorer"
        if path:
            if not path.find('OR') > -1 and not path.find('AND') > -1:
                path = escapejs(path).replace(" ", ' OR ')
            else:
                path = escapejs(path)
            now = time.time()
            self.api.query(path, False)
            done = time.time()
            return (Template(template.results,
                             default_filters=['unicode'],
                             input_encoding='utf-8').render_unicode(
                                 numfound=self.api.numfound,
                                 records=self.api.records,
                                 now=now,
                                 done=done,
                                 keyword=path,
                                 baseurl=BASEURL,
                                 api=self.api))
        return 'Hello, world!'