本文整理匯總了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