# 配置文件settings (即网页配置文件) from django.conf import settings settings.configure( DEBUG=True, SECREI_KEY=‘88888a‘, # 这个是网站的密码,保护你的网站密码不会被非法入侵 ROOT_URLCONF=__name__, MIDDLEWARE_CLASSES=( ‘django.middleware.common.CommonMiddleware‘, ‘django.middleware.csrf.CsrViewMiddleware‘, ‘django.middleware.clickjacking.XFrameOptionsMiddleware‘, ), ) # 试图网站相应的内容views(即网页内容) from django.http import HttpResponse def index(request): return HttpResponse(‘你好,世界‘) # 配置了网站地址的一个访问路径规则urls(即网页地址) from django.conf.urls import url urlpatterns = ( url(r‘^$‘, index), ) import sys if __name__ == ‘__main__‘: from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
运行:
结果: