最小的Django應用
阿新 • • 發佈:2018-04-16
style issue check .config AR click ide secret color
創建一個hello.py 內容如下:
import sys from django.conf import settings # 設置 settings.configure( DEBUG = True, SECRET_KEY = ‘thisisthe‘, ROOT_URLCONF = __name__, MIDDLEWARE_CLASSES = ( ‘django.middleware.common.CommonMiddleware‘, ‘django.middleware.csrf.CsrfViewMiddleware‘, ‘django.middleware.clickjacking.XFrameOptionsMiddleware‘, ), ) from django.conf.urls import url from django.http import HttpResponse # 創建視圖 def index(request): return HttpResponse("Hello world") # URL urlpatterns = ( url(r‘^$‘, index), ) if __name__ == "__main__": from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
終端運行:python hello.py runserver
System check identified no issues (0 silenced).
Django version 2.0.3, using settings None
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
最小的Django應用