美文网首页
Django 搭建http或https服务器

Django 搭建http或https服务器

作者: 未来与传说 | 来源:发表于2018-10-18 22:39 被阅读0次

Django之http

  1. pip install Django 安装
  2. django-admin startproject mysite 创建项目mysite项目名称
  3. python manage.py startapp myapp 创建一个应用myapp应用名称
  4. python manage.py runserver 127.0.0.1:8000 运行http服务(切换到mysite目录下)
  5. 更多详细教程参考 https://docs.djangoproject.com/zh-hans/2.2/intro/tutorial01/

Django之https

安装所需插件

pip install django-extensions
pip install django-werkzeug-debugger-runserver
pip install pyOpenSSL

配置setting.py

INSTALLED_APPS = [
    ....
    'werkzeug_debugger_runserver',
    'django_extensions',
]
SECURE_SSL_REDIRECT = True

启用服务

python manage.py runserver_plus --cert server.crt 192.168.8.250:9999
python manage.py runserver_plus --cert server.crt 192.168.8.250:443

其他
启用服务会自动创建一份证书;也可通过 openssl 客户端创建证书

相关文章

网友评论

      本文标题:Django 搭建http或https服务器

      本文链接:https://www.haomeiwen.com/subject/znyjzftx.html