示例#1
0
文件: server.py 项目: aymankh86/pico
def serve_file(file_path):
    response = Response()
    fs = os.stat(file_path)
    mimetype = mimetypes.guess_type(file_path)
    response.set_header("Content-length", str(fs.st_size))
    if file_path.endswith('.manifest'):
        response.set_header("Content-type", 'text/cache-manifest')
        response.set_header("Expires", 'access')
    else:
        response.set_header("Content-type", mimetype[0] or 'text/plain')
        response.set_header("Last-Modified", date_time_string(fs.st_mtime))
    response.content = open(file_path, 'rb')
    response.type = "file"
    return response
示例#2
0
文件: server.py 项目: natanocr/pico
def serve_file(file_path):
    response = Response()
    fs = os.stat(file_path)
    mimetype = mimetypes.guess_type(file_path)
    response.set_header("Content-length", str(fs.st_size))
    if file_path.endswith('.manifest'):
        response.set_header("Content-type", 'text/cache-manifest')
        response.set_header("Expires", 'access')
    else:
        response.set_header("Content-type", mimetype[0] or 'text/plain')
        response.set_header("Last-Modified", date_time_string(fs.st_mtime))
    response.content = open(file_path, 'rb')
    response.type = "file"
    return response
示例#3
0
def serve_file(file_path):
    response = Response()
    size = os.path.getsize(file_path)
    mimetype = mimetypes.guess_type(file_path)
    response.set_header("Content-type", mimetype[0] or 'text/plain')
    response.set_header("Content-length", str(size))
    response.set_header("Cache-Control", 'public, max-age=22222222')
    response.content = open(file_path, 'rb')
    response.type = "file"
    return response
示例#4
0
def serve_file(file_path):
    response = Response()
    size = os.path.getsize(file_path)
    mimetype = mimetypes.guess_type(file_path)
    response.set_header("Content-type", mimetype[0] or 'text/plain')
    response.set_header("Content-length", str(size))
    response.set_header("Cache-Control", 'public, max-age=22222222')
    response.content = open(file_path, 'rb')
    response.type = "file"
    return response