本文整理汇总了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': []}
示例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)
示例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)
示例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)
示例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)
示例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
示例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)
示例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
示例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