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


Python server.listen方法代碼示例

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


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

示例1: run

# 需要導入模塊: from twisted.web import server [as 別名]
# 或者: from twisted.web.server import listen [as 別名]
def run(self, handler):
        from eventlet import wsgi, listen, patcher
        if not patcher.is_monkey_patched(os):
            msg = "Bottle requires eventlet.monkey_patch() (before import)"
            raise RuntimeError(msg)
        socket_args = {}
        for arg in ('backlog', 'family'):
            try:
                socket_args[arg] = self.options.pop(arg)
            except KeyError:
                pass
        address = (self.host, self.port)
        try:
            wsgi.server(listen(address, **socket_args), handler,
                        log_output=(not self.quiet))
        except TypeError:
            # Fallback, if we have old version of eventlet
            wsgi.server(listen(address), handler) 
開發者ID:brycesub,項目名稱:silvia-pi,代碼行數:20,代碼來源:bottle.py

示例2: route

# 需要導入模塊: from twisted.web import server [as 別名]
# 或者: from twisted.web.server import listen [as 別名]
def route(self, path=None, method='GET', **kargs):
        """ Decorator: Bind a function to a GET request path.

            If the path parameter is None, the signature of the decorated
            function is used to generate the path. See yieldroutes()
            for details.

            The method parameter (default: GET) specifies the HTTP request
            method to listen to. You can specify a list of methods.
        """
        if isinstance(method, str): #TODO: Test this
            method = method.split(';')
        def wrapper(callback):
            paths = [] if path is None else [path.strip().lstrip('/')]
            if not paths: # Lets generate the path automatically
                paths = yieldroutes(callback)
            for p in paths:
                for m in method:
                    route = m.upper() + ';' + p
                    self.routes.add(route, callback, **kargs)
            return callback
        return wrapper 
開發者ID:lrq3000,項目名稱:pyFileFixity,代碼行數:24,代碼來源:bottle2.py

示例3: route

# 需要導入模塊: from twisted.web import server [as 別名]
# 或者: from twisted.web.server import listen [as 別名]
def route(self, path=None, method='GET', **kargs):
        """ Decorator: Bind a function to a GET request path.

            If the path parameter is None, the signature of the decorated
            function is used to generate the path. See yieldroutes()
            for details.

            The method parameter (default: GET) specifies the HTTP request
            method to listen to. You can specify a list of methods. 
        """
        if isinstance(method, str): #TODO: Test this
            method = method.split(';')
        def wrapper(callback):
            paths = [] if path is None else [path.strip().lstrip('/')]
            if not paths: # Lets generate the path automatically 
                paths = yieldroutes(callback)
            for p in paths:
                for m in method:
                    route = m.upper() + ';' + p
                    self.routes.add(route, callback, **kargs)
            return callback
        return wrapper 
開發者ID:lrq3000,項目名稱:pyFileFixity,代碼行數:24,代碼來源:bottle3.py

示例4: route

# 需要導入模塊: from twisted.web import server [as 別名]
# 或者: from twisted.web.server import listen [as 別名]
def route(self, path=None, method='GET', callback=None, name=None,
              apply=None, skip=None, **config):
        """ A decorator to bind a function to a request URL. Example::

                @app.route('/hello/:name')
                def hello(name):
                    return 'Hello %s' % name

            The ``:name`` part is a wildcard. See :class:`Router` for syntax
            details.

            :param path: Request path or a list of paths to listen to. If no
              path is specified, it is automatically generated from the
              signature of the function.
            :param method: HTTP method (`GET`, `POST`, `PUT`, ...) or a list of
              methods to listen to. (default: `GET`)
            :param callback: An optional shortcut to avoid the decorator
              syntax. ``route(..., callback=func)`` equals ``route(...)(func)``
            :param name: The name for this route. (default: None)
            :param apply: A decorator or plugin or a list of plugins. These are
              applied to the route callback in addition to installed plugins.
            :param skip: A list of plugins, plugin classes or names. Matching
              plugins are not installed to this route. ``True`` skips all.

            Any additional keyword arguments are stored as route-specific
            configuration and passed to plugins (see :meth:`Plugin.apply`).
        """
        if callable(path): path, callback = None, path
        plugins = makelist(apply)
        skiplist = makelist(skip)
        def decorator(callback):
            # TODO: Documentation and tests
            if isinstance(callback, basestring): callback = load(callback)
            for rule in makelist(path) or yieldroutes(callback):
                for verb in makelist(method):
                    verb = verb.upper()
                    route = Route(self, rule, verb, callback, name=name,
                                  plugins=plugins, skiplist=skiplist, **config)
                    self.add_route(route)
            return callback
        return decorator(callback) if callback else decorator 
開發者ID:Autodesk,項目名稱:arnold-usd,代碼行數:43,代碼來源:__init__.py

示例5: run

# 需要導入模塊: from twisted.web import server [as 別名]
# 或者: from twisted.web.server import listen [as 別名]
def run(self, handler):
        from meinheld import server
        server.listen((self.host, self.port))
        server.run(handler) 
開發者ID:Autodesk,項目名稱:arnold-usd,代碼行數:6,代碼來源:__init__.py


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