diff options
author | 06180339 <mlrst@web.de> | 2017-01-28 23:29:29 +0100 |
---|---|---|
committer | Juerg Haefliger <juergh@protonmail.com> | 2022-05-24 08:57:52 +0200 |
commit | 888aa8e7b8f6490015463ee370ff4026fc951b1f (patch) | |
tree | 80cc1f1da89c5746ab38c33e876654211bca122f /bottle.py | |
parent | e1be22df61b9d545b7af3d8990603f4782eecced (diff) | |
download | bottle-888aa8e7b8f6490015463ee370ff4026fc951b1f.tar.gz |
Add ServerAdapter for CherryPy >= 9
Since CherryPy >= 9, the server part of CherryPy has been extracted and named Cheroot. Thus the old CherryPy ServerAdapter does not work for CherryPy >= 9: the import fails, and the SSL part should be different too. Cheroot can be installed (git install cheroot) without CherryPy so that we can just have a CherootServer adapter in addition to the CherryPyServer adapter for the older versions.
(cherry picked from commit b9229eef97ea246e3d0e0c455071d54435a1557d)
Signed-off-by: Juerg Haefliger <juergh@protonmail.com>
Diffstat (limited to 'bottle.py')
-rw-r--r-- | bottle.py | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -2816,6 +2816,25 @@ class CherryPyServer(ServerAdapter): server.stop() +class CherootServer(ServerAdapter): + def run(self, handler): # pragma: no cover + from cheroot import wsgi + from cheroot.ssl import builtin + self.options['bind_addr'] = (self.host, self.port) + self.options['wsgi_app'] = handler + certfile = self.options.pop('certfile', None) + keyfile = self.options.pop('keyfile', None) + chainfile = self.options.pop('chainfile', None) + server = wsgi.Server(**self.options) + if certfile and keyfile: + server.ssl_adapter = builtin.BuiltinSSLAdapter( + certfile, keyfile, chainfile) + try: + server.start() + finally: + server.stop() + + class WaitressServer(ServerAdapter): def run(self, handler): from waitress import serve |