Esempio n. 1
0
    """
    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()
Esempio n. 2
0
#!/usr/bin/env python

from brubeck.request_handling import Brubeck
from brubeck.templating import MustacheRendering, load_mustache_env
from brubeck.connections import Mongrel2Connection


class DemoHandler(MustacheRendering):
    def get(self):
        name = self.get_argument("name", "dude")
        context = {"name": name}
        return self.render_template("success", **context)


app = Brubeck(
    msg_conn=Mongrel2Connection("tcp://127.0.0.1:9999", "tcp://127.0.0.1:9998"),
    handler_tuples=[(r"^/brubeck", DemoHandler)],
    template_loader=load_mustache_env("./templates/mustache"),
)
app.run()
Esempio n. 3
0
        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()
Esempio n. 4
0
#!/usr/bin/env python

from brubeck.request_handling import Brubeck
from brubeck.templating import MustacheRendering, load_mustache_env
from brubeck.connections import Mongrel2Connection


class DemoHandler(MustacheRendering):
    def get(self):
        name = self.get_argument('name', 'dude')
        context = {
            'name': name,
        }
        return self.render_template('success', **context)


app = Brubeck(msg_conn=Mongrel2Connection('tcp://127.0.0.1:9999',
                                          'tcp://127.0.0.1:9998'),
              handler_tuples=[(r'^/brubeck', DemoHandler)],
              template_loader=load_mustache_env('./templates/mustache'))
app.run()
Esempio n. 5
0
                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()
Esempio n. 6
0
#!/usr/bin/env python

from brubeck.request_handling import Brubeck
from brubeck.templating import MustacheRendering, load_mustache_env

class DemoHandler(MustacheRendering):
    def get(self):
        name = self.get_argument('name', 'dude')
        context = {
            'name': name,
        }
        return self.render_template('success', **context)

app = Brubeck(mongrel2_pair=('ipc://127.0.0.1:9999', 'ipc://127.0.0.1:9998'),
              handler_tuples=[(r'^/brubeck', DemoHandler)],
              template_loader=load_mustache_env('./templates/mustache'))
app.run()
Esempio n. 7
0
                status = 200
            else:
                status['error'] = "Instruction does not exist"
                status = 404

        if self.is_json_request():
            self.set_body(json.dumps(context))
            self.set_status(status)
            return self.render()
        else:
            return self.render_template('delete_instruction', _status_code=status, **context)

V_C = VALID_URL_CHARS
config = {
    'mongrel2_pair': (RECV_SPEC, SEND_SPEC),
    'handler_tuples': [
        (r'^/?$', IndexHandler),
        (r'^/([%s]+)/?$' % V_C, UserHandler),
        (r'^/([%s]+)/instructions/?$' % V_C, InstructionCollectionHandler),
        (r'^/([%s]+)/instructions/([%s]+)/?$' % (V_C, V_C), InstructionModelHandler),
        (r'^/([%s]+)/tagged/([%s]+)/?$' % (V_C, V_C), TagCollectionHandler)],
    'template_loader': load_mustache_env(TEMPLATE_DIR),
    'cookie_secret': COOKIE_SECRET,
}

app = Brubeck(**config)
db = get_db(DB_HOST, DB_PORT, DB_NAME)
app.users = Users(db)
app.instructions = Instructions(app.users, JsonGitRepository(JSON_GIT_DIR), db)
app.run()
Esempio n. 8
0
    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()