1 #!/usr/bin/env python
2 # -*- coding:utf-8 -*-
3 #tornado模板配置
4 import tornado.ioloop
5 import tornado.web
6 class MainHandler(tornado.web.RequestHandler):
7 def get(self):
8 self.render("a1.html")
9 # self.write("a1.html")
10 settings ={
11 'template_path':'tpl',#html文件模板路径配置
12 'static_path':'static'#css,js文件路径配置
13 }
14 application = tornado.web.Application([
15 (r"/index", MainHandler),
16 ],**settings)
17 if __name__ == "__main__":
18 application.listen(8000)
19 tornado.ioloop.IOLoop.instance().start()
a1.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <title>Title</title>
6 <link rel="stylesheet" href="static/commons.css">
7 </head>
8 <body>
9 <a>s1</a>
10 </body>
11 </html>
commons.css
body{
margin: 0;
}