本文整理汇总了Python中tornado.options.options.address方法的典型用法代码示例。如果您正苦于以下问题:Python options.address方法的具体用法?Python options.address怎么用?Python options.address使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.options.options
的用法示例。
在下文中一共展示了options.address方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_httpserver
# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import address [as 别名]
def load_httpserver(self, sockets=None, **kwargs):
if not sockets:
from tornado.netutil import bind_sockets
if settings.IPV4_ONLY:
import socket
sockets = bind_sockets(options.port, options.address, family=socket.AF_INET)
else:
sockets = bind_sockets(options.port, options.address)
http_server = tornado.httpserver.HTTPServer(self.application, **kwargs)
http_server.add_sockets(sockets)
self.httpserver = http_server
return self.httpserver
示例2: main
# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import address [as 别名]
def main():
settings = {
'template_path': os.path.join(base_dir, 'templates'),
'static_path': os.path.join(base_dir, '../static/webssh_static'),
# 'cookie_secret': uuid.uuid1().hex,
# 'xsrf_cookies': True,
'debug': True
}
handlers = [
(r'/', IndexHandler),
(r'/ws', WsockHandler)
]
parse_command_line()
app = tornado.web.Application(handlers, **settings)
app.listen(options.port, options.address)
logging.info('Listening on {}:{}'.format(options.address, options.port))
IOLoop.current().start()
示例3: main
# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import address [as 别名]
def main():
server = make_app()
server.listen(options.port, options.address)
autoreload.start()
autoreload.watch(config_path.web)
IOLoop.instance().start()
示例4: print_settings_info
# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import address [as 别名]
def print_settings_info(self):
if settings.DEBUG:
print('tornado version: %s' % tornado.version)
print('locale support: %s' % settings.TRANSLATIONS)
print('load apps:')
for app in settings.INSTALLED_APPS:
print(' - %s' % str(app))
print('template engine: %s' % (settings.TEMPLATE_CONFIG.template_engine or 'default'))
print('server started. development server at http://%s:%s/' % (options.address, options.port))
示例5: define
# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import address [as 别名]
def define(self, options=options):
"""
定义命令行参数,你可以自定义很多自己的命令行参数,或重写此方法覆盖默认参数
:return:
"""
try:
# 增加timerotating日志配置
options.define("log_rotate_when", type=str, default='midnight',
help=("specify the type of TimedRotatingFileHandler interval "
"other options:('S', 'M', 'H', 'D', 'W0'-'W6')"))
options.define("log_rotate_interval", type=int, default=1,
help="The interval value of timed rotating")
options.define("log_rotate_mode", type=str, default='time',
help="The mode of rotating files(time or size)")
except:
pass
options.define("port", default=8000, help="run server on it", type=int)
options.define("settings", default='', help="setting module name", type=str)
options.define("address", default='0.0.0.0', help='listen host,default:0.0.0.0', type=str)
options.define("log_patch", default=True,
help='Use ProcessTimedRotatingFileHandler instead of the default TimedRotatingFileHandler.',
type=bool)
options.define("log_port_prefix", default=None, help='add port to log file prefix.', type=bool)
options.define("logging_dir", default='', help='custom log dir.')
options.define("disable_log", default=True, help='disable tornado log function.')
示例6: main
# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import address [as 别名]
def main():
parse_command_line()
settings = get_application_settings()
handlers = [
(r'/', IndexHandler),
(r'/ws', WsockHandler)
]
app = tornado.web.Application(handlers, **settings)
app.listen(options.port, options.address)
logging.info('Listening on {}:{}'.format(options.address, options.port))
IOLoop.current().start()
示例7: app_listen
# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import address [as 别名]
def app_listen(app, port, address, server_settings):
app.listen(port, address, **server_settings)
if not server_settings.get('ssl_options'):
server_type = 'http'
else:
server_type = 'https'
handler.redirecting = True if options.redirect else False
logging.info(
'Listening on {}:{} ({})'.format(address, port, server_type)
)
示例8: main
# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import address [as 别名]
def main():
options.parse_command_line()
check_encoding_setting(options.encoding)
loop = tornado.ioloop.IOLoop.current()
app = make_app(make_handlers(loop, options), get_app_settings(options))
ssl_ctx = get_ssl_context(options)
server_settings = get_server_settings(options)
app_listen(app, options.port, options.address, server_settings)
if ssl_ctx:
server_settings.update(ssl_options=ssl_ctx)
app_listen(app, options.sslport, options.ssladdress, server_settings)
loop.start()
示例9: app_listen
# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import address [as 别名]
def app_listen(app, port, address, server_settings):
app.listen(port, address, **server_settings)
server_type = 'https' if server_settings.get('ssl_options') else 'http'
logging.info(
'Listening on {}:{} ({})'.format(address, port, server_type)
)
config_open_to_public(address, server_type)
示例10: main
# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import address [as 别名]
def main():
options.parse_command_line()
loop = tornado.ioloop.IOLoop.current()
app = make_app(make_handlers(loop, options), get_app_settings(options))
ssl_ctx = get_ssl_context(options)
server_settings = get_server_settings(options)
app_listen(app, options.port, options.address, server_settings)
if ssl_ctx:
server_settings.update(ssl_options=ssl_ctx)
app_listen(app, options.sslport, options.ssladdress, server_settings)
loop.start()
示例11: run
# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import address [as 别名]
def run(self):
while True:
app = Application()
app.listen(options.port, options.address)
IOLoop.instance().start()
示例12: test_address
# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import address [as 别名]
def test_address(self):
with self.mock_option('address', '127.0.0.1'):
command = WsCeleryCommand()
command.apply_options('wscelery', argv=['--address=foobar'])
self.assertEqual(options.address, 'foobar')
示例13: make_app
# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import address [as 别名]
def make_app(config=None):
root = path.dirname(__file__)
static_path = path.join(root, 'static')
template_path = path.join(root, 'template')
app_config = dict(static_path=static_path,
template_path=template_path,
login_url='/login')
define('port', default='8080', type=int)
define('address', default='localhost', type=str)
define('testing', default=False, type=bool)
define('repo', default=None, type=str)
define('username', default=None, type=str)
define('pwdhash', default=None, type=str)
define('autosave', default=False, type=bool)
define('autosave_interval', default='5', type=int)
define('wysiwyg', default=False, type=bool)
if config is not None:
# This should only ever be used for testing
parse_config_file(config)
else:
parse_config_file(config_path.web)
if options.testing:
app_config.update(debug=True)
server = Application(urls, **app_config)
server.settings = AttrDict(server.settings)
server.settings.repo = options.repo
server.settings.username = options.username
server.settings.pwdhash = options.pwdhash
server.settings.session = _rand_str()
server.settings.config_path = config_path
server.settings.autosave = options.autosave
server.settings.autosave_interval = options.autosave_interval
server.settings.wysiwyg = options.wysiwyg
server.git = git.bake(_cwd=server.settings.repo)
return server