2024-04-23 17:54:23 发布
网友
cyclone(python)是否支持HTTPS连接和SSL?如果是的话,你能举个例子吗?在
我已经看过了cyclone github page上的文档和代码,找不到任何对SSL的引用。但是因为很多旋风都是缠绕在一起的,也许我遗漏了一些东西。。。在
在我找到这篇文章之后,已经添加了SSL示例。在这里:https://github.com/fiorix/cyclone/tree/master/demos/ssl
从README:
cyclone is a Twisted protocol, therefore it may be used in conjunction with any other protocol implemented in Twisted.
如果Twisted支持SSL,则cyclone支持它,例如:
#file: cyclone-ssl.py import cyclone.web class IndexHandler(cyclone.web.RequestHandler): def get(self): self.write("hello world") factory = cyclone.web.Application([(r"/", IndexHandler)]) portstr = "ssl:4443:privateKey=server_key.pem:certKey=server_cert.pem" # make twisted app from twisted.application import service, strports application = service.Application("cyclone-ssl") strports.service(portstr, factory).setServiceParent(application)
运行方式:
激活ssl的部分是portstr。它指定服务器在4443端口上服务,并使用server_key.pem作为其私钥,server_cert.pem作为证书。在
portstr
4443
server_key.pem
server_cert.pem
在我找到这篇文章之后,已经添加了SSL示例。在这里:https://github.com/fiorix/cyclone/tree/master/demos/ssl
从README:
如果Twisted支持SSL,则cyclone支持它,例如:
运行方式:
^{pr2}$激活ssl的部分是
portstr
。它指定服务器在4443
端口上服务,并使用server_key.pem
作为其私钥,server_cert.pem
作为证书。在相关问题 更多 >
编程相关推荐