python-m http.server 443--使用SSL? [英] Python -m http.server 443 -- with SSL?
本文介绍了python-m http.server 443--使用SSL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$ python3 -m http.server 443 --certificate /path/to/cert
推荐答案
不是从命令行,但是编写一个简单的脚本来执行此操作非常简单。
from http.server import HTTPServer, BaseHTTPRequestHandler
import ssl
httpd = HTTPServer(('localhost', 4443), BaseHTTPRequestHandler)
httpd.socket = ssl.wrap_socket(
httpd.socket,
keyfile="path/to/key.pem",
certfile='path/to/cert.pem',
server_side=True)
httpd.serve_forever()
如果您不局限于标准库并且可以安装pip包,则还有许多其他选项,例如,您可以安装接受命令行选项的uwsgi。
这篇关于python-m http.server 443--使用SSL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文