Bottle web framework - How to stop?

前端 未结 11 1328
不知归路
不知归路 2020-12-14 06:55

When starting a bottle webserver without a thread or a subprocess, there\'s no problem. To exit the bottle app -> CTRL + c.

In a thread, ho

11条回答
  •  忘掉有多难
    2020-12-14 07:34

    This question was top in my google search, so i will post my answer:

    When the server is started with the Bottle() class, it has a method close() to stop the server. From the source code:

    """ Close the application and all installed plugins. """

    For example:

    class Server:
        def __init__(self, host, port):
            self._host = host
            self._port = port
            self._app = Bottle()
        def stop(self):
            # close ws server
            self._app.close()
        def foo(self):
            # More methods, routes...
    

    Calling stop method will stop de server.

提交回复
热议问题