Parameter in the page URL

0

Sorry, I need to create a pyramid application to use the API .

1 - "/ quotes / < quote_number > "- Display page containing the quote returned by the API corresponding to < quote_number >.

I already know how to create a statistical page in Pyramid, but I do not know how to create a page that receives the parameter in the url.

    
asked by anonymous 10.09.2017 / 05:49

1 answer

1

Given the content of this page , you simply set the parameter in the URL between keys, such as {parametro} and use it through request.matchdict . Here's an example:

@view_config(route_name='quotes_number')
def quotes_number(request):
    return Response(request.matchdict['quote_number'])

config.add_route('quotes_number', 'quotes/{quote_number}')
    
11.09.2017 / 17:36