예제 #1
0
파일: __init__.py 프로젝트: skoenen/pyprol
    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
예제 #2
0
파일: __init__.py 프로젝트: skoenen/pyprol
    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
예제 #3
0
파일: www.py 프로젝트: lbjay/twarchive
 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)
예제 #4
0
파일: www.py 프로젝트: lbjay/twarchive
 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)
예제 #5
0
 def JSON(self, data):
     webapi.header('Content-type', 'application/json', True)
     return json.dumps(data)