本文整理汇总了Python中brubeck.request_handling.Brubeck.run方法的典型用法代码示例。如果您正苦于以下问题:Python Brubeck.run方法的具体用法?Python Brubeck.run怎么用?Python Brubeck.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类brubeck.request_handling.Brubeck
的用法示例。
在下文中一共展示了Brubeck.run方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WSGIConnection
# 需要导入模块: from brubeck.request_handling import Brubeck [as 别名]
# 或者: from brubeck.request_handling.Brubeck import run [as 别名]
"""
Flush the database occasionally.
"""
while True:
chat.flush(db_conn)
coro_lib.sleep(TIMEOUT)
#
# RUN BRUBECK RUN
#
config = {
"msg_conn": WSGIConnection(port=PORT),
"handler_tuples": [
(r"^/$", IndexHandler),
(r"^/rooms$", RoomsHandler),
(r"^/buffer$", BufferHandler),
(r"^/(?P<room>[^/]+)/?$", RoomHandler),
(r"^/(?P<room>[^/]+)/users$", UsersHandler),
(r"^/(?P<room>[^/]+)/messages$", MessagesHandler),
],
"cookie_secret": COOKIE_SECRET,
"db_conn": redis.StrictRedis(db=DB),
"template_loader": load_mustache_env(TEMPLATES_DIR),
}
onionchat = Brubeck(**config)
toilet = onionchat.pool.spawn(drain, onionchat.db_conn)
onionchat.run()
toilet.kill()
示例2: init_db_conn
# 需要导入模块: from brubeck.request_handling import Brubeck [as 别名]
# 或者: from brubeck.request_handling.Brubeck import run [as 别名]
###
# Instantiate database connection
db_conn = init_db_conn()
# Routing config
handler_tuples = [
(r'^/login', AccountLoginHandler),
(r'^/logout', AccountLogoutHandler),
(r'^/create', AccountCreateHandler),
(r'^/add_item', ListAddHandler),
(r'^/api', APIListDisplayHandler),
(r'^/$', ListDisplayHandler),
]
# Application config
config = {
'msg_conn': Mongrel2Connection('tcp://127.0.0.1:9999','tcp://127.0.0.1:9998'),
'handler_tuples': handler_tuples,
'template_loader': load_jinja2_env('./templates'),
'db_conn': db_conn,
'login_url': '/login',
'cookie_secret': 'OMGSOOOOOSECRET',
'log_level': logging.DEBUG,
}
# Instantiate app instance
app = Brubeck(**config)
app.run()
示例3: WSGIConnection
# 需要导入模块: from brubeck.request_handling import Brubeck [as 别名]
# 或者: from brubeck.request_handling.Brubeck import run [as 别名]
self.set_status(204)
else:
self.set_status(400, 'Could not submit move')
else:
self.set_status(400, 'You are not in this game')
return self.render()
###
#
# BRUBECK RUNNER
#
###
config = {
'msg_conn': WSGIConnection(port=PORT),
'handler_tuples': [(r'^/$', GameListHandler),
(r'^/create$', CreateGameHandler),
(r'^/(?P<game_name>[^/]+)$', ForwardToGameHandler),
(r'^/(?P<game_name>[^/]+)/$', GameHandler),
(r'^/(?P<game_name>[^/]+)/join$', JoinHandler),
(r'^/(?P<game_name>[^/]+)/start$', StartHandler),
(r'^/(?P<game_name>[^/]+)/move$', MoveHandler),
(r'^/(?P<game_name>[^/]+)/chat$', ChatHandler)],
'cookie_secret': COOKIE_SECRET,
'db_conn': redis.StrictRedis(db=DB),
'template_loader': load_mustache_env('./templates')
}
opengold = Brubeck(**config)
opengold.run()
示例4: post
# 需要导入模块: from brubeck.request_handling import Brubeck [as 别名]
# 或者: from brubeck.request_handling.Brubeck import run [as 别名]
it is ready.
"""
def post(self):
json_request = self.message.body
try:
# connect to backend
sock = CONTEXT.socket(zmq.REQ)
sock.connect(BACKEND_URI)
#request_obj = ast.literal_eval(json_request)
#sock.send_json(request_obj)
sock.send(json_request)
resp = sock.recv()
self.headers['Content-Type'] = 'application/json'
self.set_body(resp)
except Exception as e:
self.set_status(400,
status_msg="Invalid JSON Request: '%s', error '%s'"
% (json_request, e))
return self.render()
config.update({
'mongrel2_pair': (config[RECV_SPEC], config[SEND_SPEC]),
'handler_tuples': [(r'^/request$', RequestHandler)] })
openscrape = Brubeck(**config)
openscrape.run()
示例5: Brubeck
# 需要导入模块: from brubeck.request_handling import Brubeck [as 别名]
# 或者: from brubeck.request_handling.Brubeck import run [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from brubeck.request_handling import Brubeck
from config import config
le_app = Brubeck(**config)
if __name__ == '__main__':
le_app.run()