本文整理匯總了Python中tornado.httpserver.serve方法的典型用法代碼示例。如果您正苦於以下問題:Python httpserver.serve方法的具體用法?Python httpserver.serve怎麽用?Python httpserver.serve使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在模塊tornado.httpserver的用法示例。
在下文中一共展示了httpserver.serve方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Python代碼示例。
示例1: __init__
點讚 6
# 需要導入模塊: 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,
示例2: run
點讚 5
# 需要導入模塊: 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,
示例3: run
點讚 5
# 需要導入模塊: 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,
示例4: run
點讚 5
# 需要導入模塊: 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,
示例5: __init__
點讚 5
# 需要導入模塊: 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,
示例6: handle
點讚 5
# 需要導入模塊: 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,
示例7: run
點讚 5
# 需要導入模塊: 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,
示例8: reloader_run
點讚 5
# 需要導入模塊: 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,
示例9: reloader_run
點讚 5
# 需要導入模塊: 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,
注:本文中的tornado.httpserver.serve方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。