27 lines
905 B
Python
27 lines
905 B
Python
from django.http import HttpResponse
|
||
from django.shortcuts import render, redirect
|
||
|
||
|
||
# Create your views here.
|
||
def index(request):
|
||
# redirect重定向,permanent为True时永久重定向
|
||
return redirect("/static/new.html", permanent=True)
|
||
#return redirect("/blog/2")
|
||
# 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) + "的博客页面")
|