23 lines
751 B
Python
23 lines
751 B
Python
from django.http import HttpResponse
|
|
from django.shortcuts import render, redirect
|
|
|
|
|
|
# Create your views here.
|
|
def index(request):
|
|
print("页面请求处理中")
|
|
return render(request, 'index.html')
|
|
|
|
|
|
def blog(request, id):
|
|
#输入http://localhost:8000/blog/0会跳转到http://localhost:8000/static/error.html
|
|
if id==0:
|
|
return redirect("/static/error.html")
|
|
else:
|
|
return HttpResponse("id是" + str(id) + "的博客页面")
|
|
|
|
def blog2(request, year, month, day, id):
|
|
return HttpResponse(str(year) + '/' + str(month) + '/' + str(day) + '/' + ' id是' + str(id) + "的博客页面")
|
|
|
|
def blog3(request, year, month, day):
|
|
return HttpResponse(str(year) + '/' + str(month) + '/' + str(day) + "的博客页面")
|