博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
轻量级django 一
阅读量:5115 次
发布时间:2019-06-13

本文共 2161 字,大约阅读时间需要 7 分钟。

 

from django.http import HttpResponsefrom django.conf.urls import urlfrom django.conf import settingsimport syssettings.configure(    DEBUG = True,    SECRET_KEY = "HAHA",    ROOT_URLCONF = __name__,    MIDDLEWARE_CLASSES = (        'django.middleware.common.CommonMiddleware',        'django.middleware.csrf.CsrfViewMiddleware',        'django.middleware.clickjacking.XFrameOptionsMiddleware',        ),    )def index(request):    return HttpResponse("hello world")urlpatterns = (    url(r'^$',index),    )if __name__ == '__main__':    from django.core.management import execute_from_command_line    execute_from_command_line(sys.argv)

 

完善后

from django.http import HttpResponsefrom django.conf.urls import urlfrom django.conf import settingsfrom django.core.wsgi import get_wsgi_applicationimport sysimport osDEBUG = os.environ.get('DEBUG','on') == 'on'SECRET_KEY = os.environ.get('SECRET_KEY','=3k+l%xeb=fp@04uci&wy&ca14*@7ebxsu*6jd_ym1t3k^w)v*')ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS','localhost').split(',')settings.configure(    DEBUG = DEBUG,    SECRET_KEY = SECRET_KEY,    #ALLOWED_HOSTS = ALLOWED_HOSTS,    ALLOWED_HOSTS= ALLOWED_HOSTS,    ROOT_URLCONF = __name__,    MIDDLEWARE_CLASSES = (        'django.middleware.common.CommonMiddleware',        'django.middleware.csrf.CsrfViewMiddleware',        'django.middleware.clickjacking.XFrameOptionsMiddleware',        ),    )def index(request):    return HttpResponse("hello world")urlpatterns = (    url(r'^$',index),    )application = get_wsgi_application()if __name__ == '__main__':    from django.core.management import execute_from_command_line    execute_from_command_line(sys.argv)

 

更轻量的django

from django.conf import settingsfrom django.http import HttpResponsefrom django.conf.urls import urlsetting = {    'DEBUG':True,    'ROOT_URLCONF':__name__}settings.configure(**setting)def home(request):    return HttpResponse('hello world')urlpatterns = [url('^$',home,name='home')]if __name__ == '__main__':    import sys    from django.core.management import execute_from_command_line    execute_from_command_line(sys.argv)

python test runserver

 

转载于:https://www.cnblogs.com/Erick-L/p/7644869.html

你可能感兴趣的文章
计算数字1至10的总和
查看>>
动态合并Repeater控件数据列
查看>>
EF6 Codefirst+MySql 数据库迁移
查看>>
blasphemy - 题解
查看>>
不用js也能创建silverlight
查看>>
SPFieldLookupValue
查看>>
[MongoDB]安装MongoDB遇到问题
查看>>
How-important-is-deep-learning-in-autonomous-driving
查看>>
Oracle在Linux内核参数的修改
查看>>
Java 动态代理机制详解
查看>>
.NET 4.0中的泛型协变和反变
查看>>
2019.7.5刷题统计
查看>>
SQLi-LABS Page-2 (Adv Injections) Less23-Less26
查看>>
【Android Studio安装部署系列】十九、Android studio使用SVN
查看>>
JS中$含义及用法
查看>>
python与编码
查看>>
前端问题总结
查看>>
SVN添加用户权限
查看>>
【转】Emgu 图像阈值
查看>>
JavaWeb项目开发案例精粹-第6章报价管理系统-001需求分析及设计
查看>>