<s> import brukva <EOL> import tornado . httpserver <EOL> import tornado . web <EOL> import tornado . websocket <EOL> import tornado . ioloop <EOL> from functools import partial <EOL> import redis <EOL> r = redis . Redis ( db = <NUM_LIT:9> ) <EOL> async = partial ( brukva . adisp . async , cbname = '<STR_LIT>' ) <EOL> c = brukva . Client ( ) <EOL> c . connect ( ) <EOL> c . select ( <NUM_LIT:9> ) <EOL> c . set ( '<STR_LIT:foo>' , '<STR_LIT:bar>' ) <EOL> c . set ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class BrukvaHandler ( tornado . web . RequestHandler ) : <EOL> @ tornado . web . asynchronous <EOL> @ brukva . adisp . process <EOL> def get ( self ) : <EOL> ( ( _ , foo ) , ( _ , foo2 ) ) = yield [ async ( c . get ) ( '<STR_LIT:foo>' ) , async ( c . get ) ( '<STR_LIT>' ) ] <EOL> self . set_header ( '<STR_LIT:Content-Type>' , '<STR_LIT>' ) <EOL> self . write ( foo ) <EOL> self . write ( foo2 ) <EOL> self . finish ( ) <EOL> class RedisHandler ( tornado . web . RequestHandler ) : <EOL> def get ( self ) : <EOL> foo = r . get ( '<STR_LIT:foo>' ) <EOL> foo2 = r . get ( '<STR_LIT>' ) <EOL> self . set_header ( '<STR_LIT:Content-Type>' , '<STR_LIT>' ) <EOL> self . write ( foo ) <EOL> self . write ( foo2 ) <EOL> self . finish ( ) <EOL> class HelloHandler ( tornado . web . RequestHandler ) : <EOL> def get ( self ) : <EOL> self . set_header ( '<STR_LIT:Content-Type>' , '<STR_LIT>' ) <EOL> self . write ( '<STR_LIT>' ) <EOL> self . finish ( ) <EOL> application = tornado . web . Application ( [ <EOL> ( r'<STR_LIT>' , BrukvaHandler ) , <EOL> ( r'<STR_LIT>' , RedisHandler ) , <EOL> ( r'<STR_LIT>' , HelloHandler ) , <EOL> ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> http_server = tornado . httpserver . HTTPServer ( application ) <EOL> http_server . listen ( <NUM_LIT> ) <EOL> tornado . ioloop . IOLoop . instance ( ) . start ( ) </s>
