本文整理汇总了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)
示例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
示例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()