码迷,mamicode.com
首页 > 其他好文 > 详细

最小的Django应用

时间:2018-04-15 22:59:08      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:his   serve   height   tin   develop   comm   nbsp   wmi   middle   

 

创建一个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应用

标签:his   serve   height   tin   develop   comm   nbsp   wmi   middle   

原文地址:https://www.cnblogs.com/kaid/p/8849690.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!