baseimage-tutorial-framework/component_example.py
2017-11-27 21:08:31 +01:00

33 lines
671 B
Python

import codecs
from tornado.ioloop import IOLoop
from component import Component
def echo_handler(data):
return data
def rot13_handler(data):
data['data'] = codecs.encode(data['data'], 'rot13')
return data
def change_case_handler(data):
data['data'] = data['data'].upper() if data['data'].islower() else data['data'].lower()
return data
def reverse_handler(data):
data['data'] = data['data'][::-1]
return data
if __name__ == '__main__':
anchor_a = Component('anchor_a', change_case_handler)
anchor_b = Component('anchor_b', rot13_handler)
anchor_c = Component('anchor_c', reverse_handler)
IOLoop.instance().start()