django-admin.py startproject zqxt_views
cd zqxt_views
python manage.py startapp calc
zqxt_views/urls.py
from calc import views as calc_views
urlpatterns = [
path('add/', calc_views.add, name='add'), # new
]
calc/views.py
from django.shortcuts import render
from django.http import HttpResponse
def add(request):
a = request.GET['a']
b = request.GET['b']
c = int(a)+int(b)
return HttpResponse(str(c))
python manage.py runserver 8002
http://127.0.0.1:8002/add/?a=4&b=5
calc/views.py
def add2(request, a, b):
c = int(a) + int(b)
return HttpResponse(str(c))
zqxt_views/urls.py
path('add/<int:a>/<int:b>/', calc_views.add2, name='add2'),
python manage.py runserver 8002
http://127.0.0.1:8002/add/4/53/