-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathviews.py
23 lines (20 loc) · 914 Bytes
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from django.shortcuts import render
from django.http import HttpResponseRedirect, HttpResponse, HttpResponseNotFound
from django.core.urlresolvers import reverse
from TeraDictV3.apps import Teradictv3Config
Teradictv3Config.lvs.sort()
# Create your views here.
def index(request):
if request.method == 'GET':
return render(request, 'TeraDictV3/index.html', { 'lvs': Teradictv3Config.lvs, 'inlang': request.session.get('inlang',''), 'outlang': request.session.get('outlang','') })
else:
return HttpResponseNotFound('not found')
def set(request):
if request.method == 'POST':
if 'param' in request.POST and 'value' in request.POST and (request.POST['param'] == 'inlang' or request.POST['param'] == 'outlang'):
request.session[request.POST['param']] = request.POST['value']
return HttpResponse(status=200)
else:
return HttpResponse(status=409)
else:
return HttpResponseNotFound('not found')