Created
January 17, 2024 17:54
-
-
Save ichux/0c0f569a360d0ef1ebf61a86344fb45e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
from django.core.wsgi import get_wsgi_application | |
from webob import Request | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") | |
application = get_wsgi_application() | |
for path in ["/polls/", "/polls/patch/"]: | |
request = Request.blank(f"http://localhost{path}") | |
response = request.get_response(application) | |
try: | |
print(response.json()) | |
except json.decoder.JSONDecodeError: | |
print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment