Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
Returns the Content-Type string matching extension of the given filename.

        def contenttype(filename, default='text/plain'):
    """
    Returns the Content-Type string matching extension of the given filename.
    """

    i = filename.rfind('.')
    if i>= 0:
        default = CONTENT_TYPE.get(filename[i:].lower(),default)
        j = filename.rfind('.', 0, i)
        if j>=0:
            default = CONTENT_TYPE.get(filename[j:].lower(),default)
    if default.startswith('text/'):
        default += '; charset=utf-8'
    return default
        


src/j/2/j25framework-0.5.8/j25/web.py   j25framework(Download)
#Contract 
from j25.exceptions import HttpExceptions
from j25.exceptions.HttpExceptions import HTTPResponse, Http404, Http403
from j25.http import HttpResponse
from j25.http.contenttype import contenttype
        fsize = stat_file[stat.ST_SIZE]
        mtime = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(stat_file[stat.ST_MTIME]))
        self.set_contenttype(contenttype(filename))
        self.add_header('Last-Modified', mtime)
        self.add_header('Content-Transfer-Encoding', 'binary')