我正在通过CherryPy Cheroot WSGI服务器的HTTP方式运行Python 2.7 Flask应用程序,如下所示。
from cheroot.wsgi import Server as WSGIServer
from cheroot.wsgi import PathInfoDispatcher as WSGIPathInfoDispatcher
from MyFlaskApp import app
d = WSGIPathInfoDispatcher({'/': app})
server = WSGIServer(('0.0.0.0', 80), d)
if __name__ == '__main__':
try:
server.start()
except KeyboardInterrupt:
server.stop()
我需要做些什么才能从此处迁移到HTTPS? 我找到了以下指示,但似乎不适用于我的应用程序。
from cheroot.server import HTTPServer
from cheroot.ssl.builtin import BuiltinSSLAdapter
HTTPServer.ssl_adapter = BuiltinSSLAdapter(
certificate='cert/domain.crt',
private_key='cert/domain.key')
我可以将上述示例应用于我的Cheroot Flask应用程序吗?如果不行,你能提供一个简单的示例,用于Flask在Cheroot下开启HTTPS服务吗?
my_app = WSGIPathInfoDispatcher({'/': app})
这一行,并直接将app
提供给 WSGI 服务器。 - webknjaz -- Слава Україні