Django之helloword实现

首先我们新建一个Django项目
python之Django入门helloword实现_网络通信
然后它自动会生成一些配置文件
python之Django入门helloword实现_控制台输入_02
templates:模板目录
setting.py:主配置文件
urls.py:url路径文件
wsgi.py:网络通信接口
manage.py:Django管理主程序(启动服务就是靠它)

然后新建一个py文件,helloword测试

#coding=utf-8

from django.http import HttpResponse

def start(request):
    return  HttpResponse('hello word')

然后在urls.py中配置好对应路径和路径名

from django.conf.urls import url
from .import helloword

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^hello/', helloword.start)
]

然后在你的Terminal控制台输入:python manage.py runserver
python之Django入门helloword实现_Python之Django入门_03
然后就能在浏览器输入 http://127.0.0.1:8000/hello/
就能进入你的helloword了,中间可能会出现报错,丢失模块,但是不影响你的运行
python之Django入门helloword实现_控制台输入_04