KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
# /test{.format} no longer seems to work... config.add_route('test', '/test.{ext}', view='ms.views.test') views.py: from pyramid.response import Response from pyramid.renderers import render import json def test(request): extension = request.matchdict['ext'] variables = {'name' : 'blah', 'asd' : 'sdf'} if extension == 'html': output = render('mypackage:templates/blah.pt', variables, request=request) if extension == 'json': output = json.dumps(variables) return Response(output) Is there an easier way to do this? With Pylons, it was a simple: def test(self, format='html'): c.variables = {'a' : '1', 'b' : '2'} if format == 'json': return json.dumps(c.variables) return render('/templates/blah.html') I suspect I'm approaching this the wrong way...?
Tags (comma-separated)
Save Edits
Cancel