Skip to content

Instantly share code, notes, and snippets.

@ichux
Created January 17, 2024 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ichux/0c0f569a360d0ef1ebf61a86344fb45e to your computer and use it in GitHub Desktop.
Save ichux/0c0f569a360d0ef1ebf61a86344fb45e to your computer and use it in GitHub Desktop.
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