请输入两个数字
一定要在html页面的form标签下加上
{%csrf_token%}
否则会报下面的错
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def index(request):
return render(request, './userWeb/index.html')
# 加法页面
def add(request):
return render(request, './userWeb/add.html')
# 执行加法
def doadd(request):
a = request.POST['a']
b = request.POST['b']
a = int(a)
b = int(b)
result = a + b
return HttpResponse(str(result))
path("add", add),
path("doadd", doadd),