summaryrefslogtreecommitdiff
path: root/bottle.py
diff options
context:
space:
mode:
author06180339 <mlrst@web.de>2017-01-28 23:29:29 +0100
committerJuerg Haefliger <juergh@protonmail.com>2022-05-24 08:57:52 +0200
commit888aa8e7b8f6490015463ee370ff4026fc951b1f (patch)
tree80cc1f1da89c5746ab38c33e876654211bca122f /bottle.py
parente1be22df61b9d545b7af3d8990603f4782eecced (diff)
downloadbottle-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.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/bottle.py b/bottle.py
index 04ccf7d..73886a2 100644
--- a/bottle.py
+++ b/bottle.py
@@ -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