Python‎ > ‎pyramid‎ > ‎

pyramid.view


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