于是按自己的想法写了一下:
class MonitorEditHandler(tornado.web.RequestHandler): #删除监控主机记录 def get(self, *args, **kwargs): def add(a, b) return a+b with open('./static/hosts', 'rb+') as hosts: hosts = hosts.read() self.render( "monitor/monitor_edit.html", hosts=hosts, add = add )
tornado 如何传递函数到模板,布布扣,bubuko.com
原文地址:http://blog.csdn.net/smallfish1983/article/details/38415929