视图和装饰器-1
This commit is contained in:
@@ -16,8 +16,13 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path,include
|
from django.urls import path,include
|
||||||
|
from user.views import t1,t2,t3
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
#path('admin/', admin.site.urls),
|
#path('admin/', admin.site.urls),
|
||||||
path('users/',include('user.urls'))
|
path('users/',include('user.urls')),
|
||||||
|
path('',t1),
|
||||||
|
path('index.html',t1),
|
||||||
|
path('t2/',t2),
|
||||||
|
path('a.jsp/',t3)
|
||||||
]
|
]
|
||||||
|
print(urlpatterns)
|
||||||
10
user/test.html
Normal file
10
user/test.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>test</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
我的位置是真实存在的
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
urlpatterns = []
|
from user.views import t1
|
||||||
|
urlpatterns = [
|
||||||
|
path('',t1),
|
||||||
|
]
|
||||||
|
print(urlpatterns)
|
||||||
@@ -1,3 +1,26 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from django.http import HttpResponse,HttpRequest
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
def t1(resquest:HttpResponse):
|
||||||
|
print(resquest.method)
|
||||||
|
return HttpResponse('function response ok!')
|
||||||
|
|
||||||
|
content = """"
|
||||||
|
<html>
|
||||||
|
<head><title>zhibang</title></head>
|
||||||
|
<body>
|
||||||
|
我是案例2
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
## 动态生成网页
|
||||||
|
def t2(request):
|
||||||
|
return HttpResponse(content)
|
||||||
|
|
||||||
|
## 静态网页
|
||||||
|
def t3(request):
|
||||||
|
with open(r'D:\python_project\pythonProject\user\test.html', 'rb') as f:
|
||||||
|
return HttpResponse(f.read())
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user