视图和装饰器-1

This commit is contained in:
2026-07-01 17:29:04 +08:00
parent 6000f3cf7b
commit fe14f65ed5
4 changed files with 46 additions and 4 deletions

View File

@@ -1,3 +1,26 @@
from django.shortcuts import render
from django.shortcuts import render
from django.http import HttpResponse,HttpRequest
# 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())