|
|
|
|
|
by mmerickel
5402 days ago
|
|
The ordering of your patterns matters, so that is done at config time. However it's very common to want to have unrelated code executed depending on the type of request to a URL. Pyramid will do this lookup for you, rather than polluting a gigantic view function with multiple code-paths for distinct functionality. @view_config(route_name='hello', request_method='GET')
def get_hello(request):
return Response('a GET request for %s' % request.matchdict['name'])
@view_config(route_name='hello', request_method='POST')
def post_hello(request):
return Response('stored info')
config = Configurator()
config.add_route('hello', '/hello/{name}')
config.scan()
app = config.make_wsgi_app()
|
|