栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python测试开发django(2)--templates模板与html页

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python测试开发django(2)--templates模板与html页

1.在wenny目录下新建一个templates包(包名必须是templates),再新建一个a.html文件(名称可随意命名),写入以下内容




    
    我就是最漂亮的烟火


我正在学习django,今天是2020.12.5,希望3个月内学会django

我还是从前那个少年,没有一丝丝改变,时间只不过是考验;一玉口中国,一瓦顶成家,都说国很大,其实一个家; 暖阳下,我迎芬芳; 猜猜我是谁

 2.wenny/views.py中添加

from django.shortcuts import render
from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello world! yeah...")

def haha(request):
    return render(request,'a.html')

3.在fristdemo/urls.py

from django.conf.urls import url
from wenny import views


urlpatterns = [
    url(r'^$', views.index),
    url(r'^haha$', views.haha),
]

4.打开浏览器输入 http://127.0.0.1:8000/haha

运行成功

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/966351.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号