当前位置: 首页>>代码示例>>Python>>正文


Python Server.start方法代码示例

本文整理汇总了Python中circuits.web.Server.start方法的典型用法代码示例。如果您正苦于以下问题:Python Server.start方法的具体用法?Python Server.start怎么用?Python Server.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在circuits.web.Server的用法示例。


在下文中一共展示了Server.start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CircuitsWebAdapter

# 需要导入模块: from circuits.web import Server [as 别名]
# 或者: from circuits.web.Server import start [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 start [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 start [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

示例4: Root

# 需要导入模块: from circuits.web import Server [as 别名]
# 或者: from circuits.web.Server import start [as 别名]
HTML = """\
<html>
 <head>
  <title>An example application</title>
 </head>
<body>
 <h1>This is my sample application</h1>
 Put the content here...
 <hr>
 <a href="/exit">Quit</a>
</body>
</html>
"""


class Root(Controller):

    def index(self):
        return HTML

    def exit(self):
        raise SystemExit(0)


app = Server(("0.0.0.0", 8000))
Root().register(app)
app.start()

webbrowser.open("http://127.0.0.1:8000/")
app.join()
开发者ID:ke4roh,项目名称:circuits,代码行数:32,代码来源:singleclickandrun.py


注:本文中的circuits.web.Server.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。