#!/usr/bin/env python
# -*- coding:utf-8 -*-
import tornado.ioloop
import tornado.web
INPUTS_LIST = []
class MainHandler(tornado.web.RequestHandler):
def get(self):
# self.write("Hello, world")
self.render('s2.html',xxxooo = INPUTS_LIST)
def post(self, *args, **kwargs):
# 获取用户提交的数据
name = self.get_argument('xxx')
INPUTS_LIST.append(name)
self.render('s2.html',xxxooo = INPUTS_LIST)
settings = {
# 模版路劲配置
'template_path':'tpl',
# 静态路劲配置 如css 和 js
'static_path':'static'
#静态文件的前缀
'static_url_prefix':'/sss/'
} # 路由映射 application = tornado.web.Application([ (r"/index", MainHandler), ] , **settings) if __name__ == "__main__": application.listen(8888) tornado.ioloop.IOLoop.instance().start()
self.get_argument()
#获取用户提交的数据
get 通过URL中传输数据
post 通过内部传输数据
{% for item in xxxooo %}
<li>{{ item }}</li>
{% end %}
{% if item == '123' %}
<li>{{ item }}</li>
{% else %}
<li>{{ item }}</li>
{% end %}
模版语言里通过for循环展示数据