Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example #14

Open
recoyou opened this issue Jun 13, 2011 · 0 comments
Open

Add example #14

recoyou opened this issue Jun 13, 2011 · 0 comments

Comments

@recoyou
Copy link

recoyou commented Jun 13, 2011

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant