FileResponse


Definition
The FileResponse load the static file from the computer and display in the browser. 

Syntax
pyramid.response.FileResponse()

Examples
The FileResponse returns with png file from disk.
from paste.httpserver import serve
from pyramid.view import view_config
from pyramid.config import Configurator
from pyramid.response import FileResponse

@view_config(route_name='png')
def turtle(file):
    view = FileResponse(
        'turtle.png',
        request=file,
        content_type='image/png'
        )
    return view

if __name__ == '__main__':
    config = Configurator()
    config.add_route('png', '/')
    config.scan('__main__')
    serve(config.make_wsgi_app())





Comments