关于使用Django框架的django-sslserver库进行https连接容易忽视的问题。

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

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连接了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值