當前位置: 首頁>>代碼示例>>Python>>正文


Python Server.stop方法代碼示例

本文整理匯總了Python中circuits.web.Server.stop方法的典型用法代碼示例。如果您正苦於以下問題:Python Server.stop方法的具體用法?Python Server.stop怎麽用?Python Server.stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在circuits.web.Server的用法示例。


在下文中一共展示了Server.stop方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: CircuitsWebAdapter

# 需要導入模塊: from circuits.web import Server [as 別名]
# 或者: from circuits.web.Server import stop [as 別名]
class CircuitsWebAdapter(object):

    class Root(Controller):
        def index(self):
            return "circuits"
        def eventSub(self):
            return "\n"

    def setup(self, host, port, app_callback):
        self._server = Server((host,port))
        self._server += Gateway(app_callback)
        self._server += self.Root()
        sfile = StaticFile('test.flac', '/mnt/nas/Anastacia/Anastacia/03 Time.flac')
        self._tree = {}
        self._tree[sfile.name] = sfile

    def start(self):
        self._server.start()

    def stop(self):
        self._server.stop()

    def application(self, environ, start_response):
        if environ['SCRIPT_NAME'] == '/':
            environ['SCRIPT_NAME'] = ''
            environ['PATH_INFO'] = '/' + environ['PATH_INFO']
            
        oldenviron = environ.copy()
        path = wsgiref.util.shift_path_info(environ)
        return self._tree[path].application(environ, start_response)
開發者ID:Viper525,項目名稱:sonospy,代碼行數:32,代碼來源:web.py

示例2: CircuitsWebAdapter

# 需要導入模塊: from circuits.web import Server [as 別名]
# 或者: from circuits.web.Server import stop [as 別名]
class CircuitsWebAdapter(AdapterInterface):
    """ circuits.web WSGI server adapter.
    """

    def setup(self, server_name, host, port, app_callback):
        from circuits.web import BaseServer, Server
        from circuits.lib.web.wsgi import Gateway
        from circuits.web import Controller
#        self._server = BaseServer(port, host)
        self._server = Server(port, host)
        self._server += Gateway(app_callback)
        self._server += Root()
#        self._server += Test()
#        self._server += eventsub()
#        self._server += handler()
        
    

    def start(self):
        self._server.start()

    def stop(self):
        self._server.stop()

    @classmethod
    def is_available(cls):
        try:
            from circuits.web import BaseServer
            from circuits.web import Controller
            from circuits.lib.web.wsgi import Gateway
            return True
        except:
            return False
開發者ID:jimmy2e,項目名稱:Sonar,代碼行數:35,代碼來源:webserver.py

示例3: test

# 需要導入模塊: from circuits.web import Server [as 別名]
# 或者: from circuits.web.Server import stop [as 別名]
def test(apps):
    server = Server(0)
    Gateway(apps).register(server)

    waiter = pytest.WaitEvent(server, "ready")
    server.start()
    waiter.wait()

    f = urlopen(server.http.base)
    s = f.read()
    assert s == b"Hello World!"

    f = urlopen("{0:s}/foobar/".format(server.http.base))
    s = f.read()
    assert s == b"FooBar!"

    server.stop()
開發者ID:AdricEpic,項目名稱:circuits,代碼行數:19,代碼來源:test_wsgi_gateway_multiple_apps.py


注:本文中的circuits.web.Server.stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。