0
我很努力设置龙卷风web应用程序,以便每次刷新html页面(或更好的没有刷新)后插入MySQL表中的新记录,呈现的html表格中的数据将会更新。龙卷风:从MySQL数据库中显示更新的数据在html表中
请求处理程序代码如下:
class TestHandler(tornado.web.RequestHandler):
def get(self):
data=sess.query(Country).all()
self.render("test.html", data=data)
HTML表格代码如下:
<table id="example" >
<thead>
<tr>
<th>name</th>
<th>capital</th>
</tr>
</thead>
<tbody>
{% for dt in data%}
<tr>
<td>{{dt.name}}</td>
<td>{{dt.capital}}</td>
</tr>
{% end %}
</tbody>
</table>
目前HTML表不更新就从MySQL表中的任何更新侧。只有在重新启动龙卷风服务器时,才会显示新数据。这个问题可能很简单,但我真的需要一些指导。