创建一个应用
在创建的项目目录下执行
python manage.py startapp blog
在blog 文件夹下的 views.py 编写代码
from django.http import HttpResponse def index(request): return HttpResponse('Hello World')
HttpResponse 用来向网页返回内容 类似 print
定义的index()函数,第一个参数必须是request
定义视图函数相关的URL(网址) (即规定 访问什么网址对应什么内容)
添加在项目目录下的 urls,py中
打开服务器(见补充) 在浏览器中输入 127.0.0.1:8000 可见