我想創建一個Django你好世界應用程序。服務器不啓動你好世界應用程序
我有以下代碼:
import sys
from django.conf import settings
from django.http import HttpResponse
settings.configure(
DEBUG=True,
SECRET_KEY='badkey',
ROOT_URLCONF=sys.modules[__name__],
)
def index(request):
return HttpResponse('Hello, World')
urlpatterns = [
(r'^hello-world/$', index),
]
位於/smartQuiz/smartQuiz/hello.py
,其中smartQuiz
是我的項目的根目錄。
如果我從hello.py
所在的目錄運行python hello.py runserver
,服務器將無法啓動。
我在做什麼錯?
你會得到什麼錯誤? – jape
這真的不是你如何運行Django。是什麼讓你認識到這會起作用? –
我沒有收到任何錯誤。我沒有收到任何消息。我在這裏看:https://ultimatedjango.com/learn-django/lessons/create-the-hello-world-web-app/ – octavian