mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 16:31:21 +00:00
33 lines
671 B
Python
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()
|