Repository navigation
Expand file tree
/
Copy pathweb.py
More file actions
49 lines (39 loc) · 1.3 KB
/
Copy pathweb.py
File metadata and controls
49 lines (39 loc) · 1.3 KB
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
43
44
45
46
47
48
49
# encoding: utf-8
__author__ = 'zhanghe'
import os
import tornado.httpserver
import tornado.web
import tornado.ioloop
import tornado.options
# from handlers import *
from tornado.options import define, options
define("port", default=8000, help="run on the given port", type=int)
class IndexHandler(tornado.web.RequestHandler):
def data_received(self, chunk):
pass
def get(self):
self.render('index.html')
def post(self):
self.render('index.html')
handlers = [
(r'/', IndexHandler),
# (r'/member', memberHandler),
# (r'/chat/(\d+)', chatHandler),
# (r'/register', registerHandler),
# (r'/logout', logoutHandler),
# (r'/post', postHandler),
# (r'/user/(\w+)', userHandler),
# (r'/blog/(\d+)', blogHandler),
# (r'/comment', commentHandler),
]
settings = {
'static_path': os.path.join(os.path.dirname(__file__), 'static'),
'template_path': os.path.join(os.path.dirname(__file__), 'template'),
}
if __name__ == '__main__':
tornado.options.parse_command_line()
app = tornado.web.Application(handlers, **settings)
# http_server = tornado.httpserver.HTTPServer(app)
# http_server.listen(options.port)
app.listen(options.port) # 貌似这一句可以替代上面两句,待研究
tornado.ioloop.IOLoop.instance().start()