from pyramid.config import Configurator def main(global_config, **settings): config = Configurator(settings=settings) config.add_cors_preflight_handler() # Add your views here return config.make_wsgi_app()
from pyramid.config import Configurator def main(global_config, **settings): config = Configurator(settings=settings) config.add_cors_preflight_handler( allowed_methods='POST,PUT,DELETE', allowed_origins='https://example.com', ) # Add your views here return config.make_wsgi_app()In this example, the preflight handler only allows POST, PUT, and DELETE requests from the https://example.com origin. The package library for Pyramid is simply called "pyramid", and the add_cors_preflight_handler method is part of the pyramid.config module.