Cookies not showing up in environ
Jon Ribbens
jon+usenet at unequivocal.eu
Sat Jul 21 09:20:59 EDT 2018
On 2018-07-20, abc abc <useracct222 at gmail.com> wrote:
> Well, I'm so messed up between so many sources and tutorials I don't
> know which way is up.
I think one of the main issues is that you don't seem to have decided
whether you're writing a WSGI application or a Django application.
WSGI:
def application(environ, start_response):
start_response('200 OK',
[('Content-Type', 'text/plain; charset=utf-8')])
return [environ.get('HTTP_COOKIE', '').encode('utf-8')]
Django:
views.py:
from django.http import HttpResponse
def cookies(request):
return HttpResponse(repr(request.COOKIES),
'text/plain; charset=utf-8')
urls.py:
from django.urls import path
from . import views
urlpatterns = [
path('cookies', views.cookies),
]
More information about the Python-list
mailing list