Titivillus/set_session/views.py

20 lines
430 B
Python
Raw Normal View History

#!/usr/bin/env python3
"""
/set_session app views.
"""
from django.http import HttpResponse
def index(request):
"""
A simple API endpoint for setting certain values in the users session.
"""
2018-09-20 13:09:24 -04:00
for key, value in request.POST.items():
if key not in ['hide_header', 'hide_chat']:
continue
if value == 'on':
request.session[key] = True
elif value == 'off':
request.session[key] = False
return HttpResponse('true')