From fe14f65ed536da5dbcf3bec4b0e8b3df6ed69143 Mon Sep 17 00:00:00 2001 From: xingzhibang <775288271@qq.com> Date: Wed, 1 Jul 2026 17:29:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E5=9B=BE=E5=92=8C=E8=A3=85=E9=A5=B0?= =?UTF-8?q?=E5=99=A8-1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mamonth/urls.py | 9 +++++++-- user/test.html | 10 ++++++++++ user/urls.py | 6 +++++- user/views.py | 25 ++++++++++++++++++++++++- 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 user/test.html diff --git a/mamonth/urls.py b/mamonth/urls.py index 3e21009..1058141 100644 --- a/mamonth/urls.py +++ b/mamonth/urls.py @@ -16,8 +16,13 @@ Including another URLconf """ from django.contrib import admin from django.urls import path,include - +from user.views import t1,t2,t3 urlpatterns = [ #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) \ No newline at end of file diff --git a/user/test.html b/user/test.html new file mode 100644 index 0000000..de90d97 --- /dev/null +++ b/user/test.html @@ -0,0 +1,10 @@ + + + + + test + + + 我的位置是真实存在的 + + \ No newline at end of file diff --git a/user/urls.py b/user/urls.py index 4736091..6198e2d 100644 --- a/user/urls.py +++ b/user/urls.py @@ -1,3 +1,7 @@ from django.contrib import admin from django.urls import path -urlpatterns = [] +from user.views import t1 +urlpatterns = [ + path('',t1), +] +print(urlpatterns) \ No newline at end of file diff --git a/user/views.py b/user/views.py index 91ea44a..daeeef2 100644 --- a/user/views.py +++ b/user/views.py @@ -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 = """" + +zhibang + + 我是案例2 + + +""" +## 动态生成网页 +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()) + +