欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

django的hello world

程序员文章站 2022-07-02 20:53:23
==================hello.py================================= ======================================================== 运行命令: python hello.py runserver ......

==================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