Skip to content
This repository

Add example #14

Open
recoyou opened this Issue June 13, 2011 · 0 comments

1 participant

recoyou
recoyou

Please add examples, Its takes few hours to understand that module works:

On Windows:
c = brukva.Client(host = '127.0.0.1')

Example:
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web

from tornado.options import define, options

define("port", default=8888, help="run on the given port", type=int)

import logging
import brukva
from brukva import adisp

logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger('app')

c = brukva.Client()
c.connect()

class MainHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
@adisp.process
def get(self):
yield c.async.set('hello', 'Hello, world')
foo = yield c.async.get('hello')
self.write(foo)
self.finish()

def main():
tornado.options.parse_command_line()
application = tornado.web.Application([
(r"/", MainHandler),
])
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()

if name == "main":
main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.