diff --git a/component_example.py b/component_example.py new file mode 100644 index 0000000..f53b672 --- /dev/null +++ b/component_example.py @@ -0,0 +1,32 @@ +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()