标签:create 文件夹 nbsp cut 网址 request username color word
1 1创建项目 first_pro 2 2创建app app01 3 做一个登录页面的web项目,浏览器输入一个网址得到一个web页面 4 5 用户: http:127.0.0.1:8001/login/ 6 7 1urls.py 8 from django.conf.urls import url from django.contrib import admin from app01 import views 9 10 urlpatterns = [ 11 # url(r‘^admin/‘, admin.site.urls), 12 url(r‘^index/‘, views.index), #配置路径,r‘^/index/‘,这个前置导航斜杠不需要添加. 13 ] 14 15 2写逻辑视图 16 from django.shortcuts import render,HttpResponse # Create your views here. 17 18 def index(request): print(request.method) #‘POST‘ ‘GET‘ if request.method == ‘GET‘: 19 return render(request,‘login.html‘) else: 20 # print(request.GET) print(request.POST) 21 username = request.POST.get(‘username‘) password = request.POST.get(‘password‘) 22 if username == ‘dazhuang‘ and password == ‘123‘: return HttpResponse(‘登录成功!‘) 23 else: 24 return HttpResponse(‘登录失败!‘) 25 26 3创建html文件 27 在templates文件夹中创建一个login.html文件
标签:create 文件夹 nbsp cut 网址 request username color word
原文地址:https://www.cnblogs.com/ch2020/p/13053004.html