Exemplo n.º 1
0
    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
Exemplo n.º 2
0
        def get_index(request):
            data = {
                'message': 'Hello world!',
                'request': request.as_dict(),
            }

            return template_or_json_response(request, 'index.html', data)