Pyramid Web Framework

2.1 · active · verified Fri Apr 10

Pyramid is a minimalistic, flexible, and open-source Python web framework that prioritizes simplicity, scalability, and ease of use. It is part of the Pylons Project and is currently at version 2.1, with releases typically following a maintenance and deprecation policy where deprecated features are kept for at least three minor releases before removal. [1, 2, 12, 16]

Warnings

Install

Imports

Quickstart

This minimal 'hello world' application demonstrates the core components of a Pyramid web application: `Configurator` for application setup, `add_route` to define a URL pattern, `add_view` to link a view callable to a route, and `Response` to return content. It uses `wsgiref.simple_server` to serve the application directly. [2, 5, 12]

from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response

def hello_world(request):
    return Response('Hello World!')

if __name__ == '__main__':
    with Configurator() as config:
        config.add_route('hello', '/')
        config.add_view(hello_world, route_name='hello')
        app = config.make_wsgi_app()
    server = make_server('0.0.0.0', 6543, app)
    print('Serving on http://0.0.0.0:6543')
    server.serve_forever()

view raw JSON →