问题描述:
在实现通过H5实现录音功能的时候需要调用用户的录音模块,但是chrome浏览器不能正常调用麦克风,经过一番查询,得知需要将HTTP转换为HTTPS。
- 有问题的状态
- 解决后的状态
解决方法
1.安装python-django需要的库
pip install django-extensions
pip install django-werkzeug-debugger-runserver
pip install pyOpenSSL
2.在django工程setting.py的 INSTALLED_APPS 下添加
'werkzeug_debugger_runserver',
'django_extensions',
3.生成密匙和证书文件
python manage.py runserver_plus --cert-file cert.crt
完成后会发现django
工程中出现两个文件cert.crt
和cert.key
4. 以HTTPS方式运行django
python manage.py runserver_plus --cert cert.crt 0.0.0.0:8000
参考地址:
https://django-extensions.readthedocs.io/en/latest/runserver_plus.html#certificates-paths