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


Python httpserver.serve方法代码示例

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


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

示例1: __init__

# 需要导入模块: from tornado import httpserver [as 别名]
# 或者: from tornado.httpserver import serve [as 别名]
def __init__(self, catchall=True, autojson=True, config=None):
        """ Create a new bottle instance.
            You usually don't do that. Use `bottle.app.push()` instead.
        """
        self.routes = [] # List of installed routes including metadata.
        self.callbacks = {} # Cache for wrapped callbacks.
        self.router = Router() # Maps to self.routes indices.

        self.mounts = {}
        self.error_handler = {}
        self.catchall = catchall
        self.config = config or {}
        self.serve = True
        self.castfilter = []
        if autojson and json_dumps:
            self.add_filter(dict, dict2json)
        self.hooks = {'before_request': [], 'after_request': []} 
开发者ID:gabrielStanovsky,项目名称:props,代码行数:19,代码来源:bottle.py

示例2: run

# 需要导入模块: from tornado import httpserver [as 别名]
# 或者: from tornado.httpserver import serve [as 别名]
def run(self, handler):
        from waitress import serve
        serve(handler, host=self.host, port=self.port) 
开发者ID:Autodesk,项目名称:arnold-usd,代码行数:5,代码来源:__init__.py

示例3: run

# 需要导入模块: from tornado import httpserver [as 别名]
# 或者: from tornado.httpserver import serve [as 别名]
def run(self, handler): # pragma: no cover
        from paste import httpserver
        if not self.quiet:
            from paste.translogger import TransLogger
            handler = TransLogger(handler)
        httpserver.serve(handler, host=self.host, port=str(self.port),
                         **self.options) 
开发者ID:zhangzhengde0225,项目名称:VaspCZ,代码行数:9,代码来源:bottle.py

示例4: run

# 需要导入模块: from tornado import httpserver [as 别名]
# 或者: from tornado.httpserver import serve [as 别名]
def run(self, handler):
        from waitress import serve
        serve(handler, host=self.host, port=self.port, _quiet=self.quiet, **self.options) 
开发者ID:brycesub,项目名称:silvia-pi,代码行数:5,代码来源:bottle.py

示例5: __init__

# 需要导入模块: from tornado import httpserver [as 别名]
# 或者: from tornado.httpserver import serve [as 别名]
def __init__(self, catchall=True, autojson=True, path = ''):
        """ Create a new bottle instance.
            You usually don't do that. Use `bottle.app.push()` instead.
        """
        self.routes = Router()
        self.mounts = {}
        self.error_handler = {}
        self.catchall = catchall
        self.config = dict()
        self.serve = True
        self.castfilter = []
        if autojson and json_dumps:
            self.add_filter(dict, dict2json) 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:15,代码来源:bottle2.py

示例6: handle

# 需要导入模块: from tornado import httpserver [as 别名]
# 或者: from tornado.httpserver import serve [as 别名]
def handle(self, url, method):
        """ Execute the handler bound to the specified url and method and return
        its output. If catchall is true, exceptions are catched and returned as
        HTTPError(500) objects. """
        if not self.serve:
            return HTTPError(503, "Server stopped")

        handler, args = self.match_url(url, method)
        if not handler:
            return HTTPError(404, "Not found:" + url)

        try:
            return handler(**args)
        except HTTPResponse, e:
            return e 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:17,代码来源:bottle2.py

示例7: run

# 需要导入模块: from tornado import httpserver [as 别名]
# 或者: from tornado.httpserver import serve [as 别名]
def run(self, handler): # pragma: no cover
        from paste import httpserver
        from paste.translogger import TransLogger
        app = TransLogger(handler)
        httpserver.serve(app, host=self.host, port=str(self.port), **self.options) 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:7,代码来源:bottle2.py

示例8: reloader_run

# 需要导入模块: from tornado import httpserver [as 别名]
# 或者: from tornado.httpserver import serve [as 别名]
def reloader_run(server, app, interval):
    if os.environ.get('BOTTLE_CHILD') == 'true':
        # We are a child process
        files = dict()
        for module in sys.modules.values():
            file_path = getattr(module, '__file__', None)
            if file_path and os.path.isfile(file_path):
                file_split = os.path.splitext(file_path)
                if file_split[1] in ('.py', '.pyc', '.pyo'):
                    file_path = file_split[0] + '.py'
                    files[file_path] = os.stat(file_path).st_mtime
        thread.start_new_thread(server.run, (app,))
        while True:
            time.sleep(interval)
            for file_path, file_mtime in files.iteritems():
                if not os.path.exists(file_path):
                    print "File changed: %s (deleted)" % file_path
                elif os.stat(file_path).st_mtime > file_mtime:
                    print "File changed: %s (modified)" % file_path
                else: continue
                print "Restarting..."
                app.serve = False
                time.sleep(interval) # be nice and wait for running requests
                sys.exit(3)
    while True:
        args = [sys.executable] + sys.argv
        environ = os.environ.copy()
        environ['BOTTLE_CHILD'] = 'true'
        exit_status = subprocess.call(args, env=environ)
        if exit_status != 3:
            sys.exit(exit_status)






# Templates 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:40,代码来源:bottle2.py

示例9: reloader_run

# 需要导入模块: from tornado import httpserver [as 别名]
# 或者: from tornado.httpserver import serve [as 别名]
def reloader_run(server, app, interval):
    if os.environ.get('BOTTLE_CHILD') == 'true':
        # We are a child process
        files = dict()
        for module in list(sys.modules.values()):
            file_path = getattr(module, '__file__', None)
            if file_path and os.path.isfile(file_path):
                file_split = os.path.splitext(file_path)
                if file_split[1] in ('.py', '.pyc', '.pyo'):
                    file_path = file_split[0] + '.py'
                    files[file_path] = os.stat(file_path).st_mtime
        _thread.start_new_thread(server.run, (app,))
        while True:
            time.sleep(interval)
            for file_path, file_mtime in files.items():
                if not os.path.exists(file_path):
                    print("File changed: %s (deleted)" % file_path)
                elif os.stat(file_path).st_mtime > file_mtime:
                    print("File changed: %s (modified)" % file_path)
                else: continue
                print("Restarting...")
                app.serve = False
                time.sleep(interval) # be nice and wait for running requests
                sys.exit(3)
    while True:
        args = [sys.executable] + sys.argv
        environ = os.environ.copy()
        environ['BOTTLE_CHILD'] = 'true'
        exit_status = subprocess.call(args, env=environ)
        if exit_status != 3:
            sys.exit(exit_status)






# Templates 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:40,代码来源:bottle3.py


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