django的hello world
最小化的单文件django网站实现
hello.py===============
import sys
from django.conf import settings
from django.http import HttpResponse
from django.conf.urls import url
from django.core.management import execute_from_command_line
settings.configure(
DEBUG=True,
SECRET_KEY='onlyfortest',
ROOT_URLCONF=__name__,
)
def index(request):
return HttpResponse('Hello World')
urlpatterns = (
url('^$', index),
)
if __name__ == "__main__":
execute_from_command_line(sys.argv)
========================================================
运行命令:
python hello.py runserver