tornado版本: start_app.py
java代码
# coding:gbk
import tornado.web
import tornado.wsgi
import wsgiref.simple_server
import sys
import for_rmzx
reload(sys)
sys.setdefaultencoding(‘gbk’)
class mainhandler_gjj(tornado.web.requesthandler):
def initialize(self,param):
self.param = param
def get(self):
# name = self.get_argument(“name”)
self.write(“hello, gjj:” + self.param)
class mainhandler_sb(tornado.web.requesthandler):
def get(self):
self.write(“hello, sb”)
class storyhandler(tornado.web.requesthandler):
def get(self, param1,param2,parma3):
self.write(“for test ref params ” + param1 + “———-” + param2 + “———-” + parma3)
if __name__ == “__main__”:
application_bjgjj = tornado.web.application([
(r”/gjj”, mainhandler_gjj, dict(param=”andy”)),
(r”/sb”, mainhandler_sb),
(r”/rmzx”, for_rmzx.mainhandler_rmzx),
(r”/api/param/([a-z]+)/([0-9]+)/([a-za-z0-9\u4e00-\u9fa5]+)”, storyhandler),
])
wsgi_app = tornado.wsgi.wsgiadapter(application_bjgjj)
server = wsgiref.simple_server.make_server(”, 5555, wsgi_app)
server.serve_forever()
for_rmzx.py
java代码
__author__ = ‘sks’
import tornado.web
import tornado.wsgi
import wsgiref.simple_server
class mainhandler_rmzx(tornado.web.requesthandler):
def get(self):
self.write(“hello, rmzx”)