标签:comment 斜杠 and 出错 cti post pwd key view
urlpatterns = [
path(‘admin/‘, admin.site.urls),
path(‘index‘,views.index), #在路径末尾加 ‘/‘ 例如:index/
path(‘login‘,views.login),
]
def index(request):
return render(request, ‘index.html‘)
def login(request):
if request.method == ‘GET‘:
return render(request, ‘login.html‘)
elif request.method == ‘POST‘:
u = request.POST.get(‘user‘,None)
p = request.POST.get(‘pwd‘,None)
if u == ‘alex‘ and p == ‘123‘:
return redirect(‘/index‘)
else:
return render(request, ‘login.html‘)
else:
return redirect(‘/index‘) # 调用时候也不要在后面加斜杠否则会出错
标签:comment 斜杠 and 出错 cti post pwd key view
原文地址:https://www.cnblogs.com/yjc-z/p/12275713.html