-
Notifications
You must be signed in to change notification settings - Fork 0
/
004escape.py
42 lines (37 loc) · 1.23 KB
/
004escape.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# coding:utf-8
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
import json
define(name='port', default=8000, help='run port', type=int)
# define(name='version', default='0.0.1', help='version 0.0.1', type=str)
class TempHandler(tornado.web.RequestHandler):
def get(self):
username = self.get_argument('name', 'no')
urllist = [
('http://www.baidu.com', '百度'),
('http://www.zhihu.com', '知乎'),
('http://www.weibo.com', '微博'),
]
atga = '<a href="http://www.baidu.com" target="_blank">__百度__</a>'
self.render('04escape.html',
username=username,
urllist=urllist,
atga=atga,
)
if __name__ == '__main__':
tornado.options.parse_command_line()
app = tornado.web.Application(
handlers=[
(r'/temp', TempHandler),
],
debug=True,
template_path='templates',
# autoescape=None,
static_path='static',
)
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()