from django.shortcuts import render from django.http import HttpResponse # Create your views here. token=r'{% csrf_token %}' calculator='''
%s
''' text="" text2="" def wr(s): with open("try.html","w") as f: f.write(calculator%(token,s)) def calc(request): global text,text2 print(request.POST) try: c=request.POST['b'] except: c='n' print(c) if c=='C' or c=='n': text="" text2="" elif c=='=': text="%f"%eval(text2) elif c=='+' or c=='-' or c=='*' or c=='/': text+=c text2+='.0'+c else: text+=c text2+=c print(text,text2) try: print(eval(text2)) except: print("qwq") wr(text) return render(request,"try.html") #HttpResponse(calculator%(0)) #if request.POST.has_key('input'):