(4) 框架主函数
my_app.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import os import json import time import logging import common_logging import common_urllib import common_conf from unipath import Path import traceback import tornado.httpserver import tornado.ioloop import tornado.options import tornado.web from tornado.options import define, options import my_handler logger = logging.getLogger(__name__) class DefaultHandler(tornado.web.RequestHandler): @tornado.web.asynchronous def get(self): res = {} self.write("success") self.finish() application = tornado.web.Application([ (r"/render", my_handler.MyHandler), (r"/", DefaultHandler), ]) if __name__ == '__main__': server = tornado.httpserver.HTTPServer(application) server.bind(cycle_render_conf.g_conf.conf["server_port"]) server.start(int(cycle_render_conf.g_conf.conf["server_thread_num"])) tornado.ioloop.IOLoop.instance().start()