Returns json in Pyramid View.
from pyramid.view import Response
from pyramid.view import view_config
@view_config(route_name='json')
def func(request):
body = u'''
{{
"key": "value"
}}
'''
return Response(body=body, headerlist=[('Content-Type', 'application/json')])
It will be returned using the Response class.
Recommended Posts