from pyramid.config import Configurator def main(global_config, **settings): config = Configurator(settings=settings) config.include('pyramid_jinja2') config.add_route('home', '/') config.scan('.views') return config.make_wsgi_app()
from pyramid.config import Configurator def my_view(request): return {'name': 'World'} if __name__ == '__main__': config = Configurator() config.add_route('hello', '/hello') config.add_view(my_view, route_name='hello', renderer='json') app = config.make_wsgi_app()In this example, we define a simple view function that returns a JSON response. We register a route for the "/hello" URL and associate our view function with it using the add_view method. We then create a WSGI application using the make_wsgi_app method. Package Library: pyramid_config.