def test_template_or_json(self): data = {"message": "Hello world!"} environ = get_environ("base") request = Request(environ) response = template_or_json_response(request, "index.html", data, template_response_class=TemplateResponseTest) assert response environ = get_environ("json-post") request = Request(environ) response = template_or_json_response(request, "index.html", data, json_response_class=JsonResponse) assert response
def get_index(request): data = { 'message': 'Hello world!', 'request': request.as_dict(), } return template_or_json_response(request, 'index.html', data)