本文整理汇总了Python中application.app方法的典型用法代码示例。如果您正苦于以下问题:Python application.app方法的具体用法?Python application.app怎么用?Python application.app使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类application
的用法示例。
在下文中一共展示了application.app方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import application [as 别名]
# 或者: from application import app [as 别名]
def main():
options.logging = None
parse_command_line()
options.subpath = options.subpath.strip('/')
if options.subpath:
options.subpath = '/' + options.subpath
# Connect to mongodb
io_loop = ioloop.IOLoop.instance()
connect(config.DB_NAME, host=config.DB_HOST, port=config.DB_PORT, io_loop=io_loop,
username=config.DB_USER, password=config.DB_PWD)
# Star application
from application import app
if options.unix_socket:
server = tornado.httpserver.HTTPServer(app)
socket = tornado.netutil.bind_unix_socket(options.unix_socket, 0o666)
server.add_socket(socket)
print('Server is running at %s' % options.unix_socket)
print('Quit the server with Control-C')
else:
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
print('Server is running at http://127.0.0.1:%s%s' % (options.port, options.subpath))
print('Quit the server with Control-C')
io_loop.start()
示例2: test_all
# 需要导入模块: import application [as 别名]
# 或者: from application import app [as 别名]
def test_all(testbed, run_tasks):
test_app = webtest.TestApp(application.app)
test_worker = webtest.TestApp(worker.app)
response = test_app.get('/')
assert '0' in response.body
test_app.post('/enqueue', {'amount': 5})
run_tasks(test_worker)
response = test_app.get('/')
assert '5' in response.body
示例3: app
# 需要导入模块: import application [as 别名]
# 或者: from application import app [as 别名]
def app():
return application.app