以下是官方网站该库的安装以及使用方法:

Project descriptio

Django SSL Server v2 is a SSL-enabled development server for the Django Framework, a clone of django-sslserver. This project is actively maintained and supports the latest version of Django and Python.

Please note that this should not be used for production setups. This app is intended for special use-cases. Most people should instead do a proper production deployment where a real webserver such as Apache or NGINX handles SSL.

Getting Started

Install the module in your Python distribution or virtualenv:

$ pip install django-sslserver-v2

Add the application to your INSTALLED_APPS:

INSTALLED_APPS = (...
"sslserver",
...
)

Start a SSL-enabled debug server:

$ python manage.py runsslserver

and access app on https://localhost:8000 or start server on specified port:

$ python manage.py runsslserver 127.0.0.1:9000

IPv6 support:

$ python manage.py runsslserver -6 [::]:7443 

You’ll now be able to access your Django app on https://localhost:9000/

 

 正常安装完成之后应该是可以直接使用的是吧?但依旧会报错,如下:

ModuleNotFoundError: No module named 'sslserver'

仍然会显示,没有该模块。最令人气愤的是找遍了网站都没人说明安装的另一个细节,正常人安装的时候都会直接安装在本地的虚拟环境的项目中,但这个库需要将包安装在与mangae.py同级目录下才能使用:

$ python manage.py runsslserver

如图所示,将包sslserver放到 mangae.py同级目录下:

就能运行成功了:

如果使用库默认的证书,记得将 证书导入到浏览器中,就能正常使用https连接了。

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐