Example #1
0
    def GET(self, name):
        ret = u''
        with codecs.open(self.filename(name), 'r', encoding='utf-8') as f:
            ret += f.read()

        header(u'Content-Type', self.content_type)
        header(u'Content-Length', self.filesize(name))
        return ret
Example #2
0
    def GET(self, name):
        ext = os.path.splitext(name)[1][1:]

        if ext == 'woff':
            self.content_type = u'application/font-woff'
        elif ext == 'ttf':
            self.content_type = u'application/octet-stream'
        elif ext == 'otf':
            self.content_type = u'application/octet-stream'
        elif ext == 'eot':
            self.content_type = u'application/octet-stream'
        elif ext == 'svg':
            self.content_type = u'application/octet-stream'
        else:
            not_found("Unknown font type.")

        ret = None
        with open(self.filename(name), 'r') as f:
            ret = f.read()

        header(u'Content-Type', self.content_type)
        header(u'Content-Length', self.filesize(name))
        return ret
Example #3
0
 def GET(self, dbname):
     db = get_database(dbname)
     collection = get_collection(db, 'tweets')
     tweets = list(collection.find({}, sort=[('_id', DESCENDING)]))
     header('Content-type', 'application/json; charset=utf-8')
     return dumps(tweets)
Example #4
0
 def GET(self, dbname):
     db = get_database(dbname)
     collection = get_collection(db, 'queries')
     queries = list(collection.find({}, sort=[('timestamp', DESCENDING)]))
     header('Content-type', 'application/json; charset=utf-8')
     return dumps(queries)
Example #5
0
 def JSON(self, data):
     webapi.header('Content-type', 'application/json', True)
     return json.dumps(data)