-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloWorld.py
More file actions
28 lines (22 loc) · 796 Bytes
/
Copy pathHelloWorld.py
File metadata and controls
28 lines (22 loc) · 796 Bytes
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
#coding:utf8
'''
Created on 2016年8月1日
@author: wolfrg
'''
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define,options
define("port",default=8000,help="run on the given port",type=int)
class IndexHandler(tornado.web.RequestHandler):
def get(self):
greeting = self.get_argument('greeting', 'Hello')
self.write(greeting + ',welcome you to read:www.baidu.com')
if __name__=="__main__":
tornado.options.parse_command_line()
#将tornado.web.Application类实例化
app = tornado.web.Application(handlers=[(r"/",IndexHandler)])
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()