django-Views之request(二)

人盡茶涼 提交于 2019-12-02 11:24:34

book/views.py

def index(request):
    http_list = {
        '<h1>请求协议:&nbsp;<span style="color:red">%s</span></h1>' % request.scheme,
        '<h1>获取完整地址:&nbsp;<span style="color:red">%s</span></h1>' % request.get_full_path(),
        '<h1>端口:&nbsp;<span style="color:red">%s</span></h1>' % request.get_port(),
        '<h1>请求方式:&nbsp;<span style="color:red">%s</span></h1>' % request.method,
        '<h1>完整url地址:&nbsp;<span style="color:red">%s</span></h1>' % request.get_raw_uri(),
    }
    return HttpResponse(http_list)

book/urls.py

from django.urls import path
from . import views
app_name ="book"
urlpatterns = [
    path('page/200/',views.index,name="index"),
]

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!