Пример #1
0
def main():
	"""主函数"""
	sm_logger.debug("**start server**")
	webConfig = WebConfigParser(WEB_CONFIG_FILE)
	urlPatterns = webConfig.urlPatterns()
	webConfig.templates()
	settings = {"static_path": os.path.join(os.path.dirname(__file__), "static"),
				'debug' : True} # 设置static静态目录
	tornado.options.parse_command_line()
	urlPatterns.append((r"/(.*)", tornado.web.StaticFileHandler, dict(path=settings['static_path'])))
	application = tornado.web.Application(urlPatterns, **settings)
	http_server = tornado.httpserver.HTTPServer(application)

	http_server.listen(options.port)
	tornado.ioloop.IOLoop.instance().start()
Пример #2
0
def main():
    """主函数"""
    sm_logger.debug("**start server**")
    webConfig = WebConfigParser(WEB_CONFIG_FILE)
    urlPatterns = webConfig.urlPatterns()
    webConfig.templates()
    settings = {
        "static_path": os.path.join(os.path.dirname(__file__), "static"),
        'debug': True
    }  # 设置static静态目录
    tornado.options.parse_command_line()
    urlPatterns.append((r"/(.*)", tornado.web.StaticFileHandler,
                        dict(path=settings['static_path'])))
    application = tornado.web.Application(urlPatterns, **settings)
    http_server = tornado.httpserver.HTTPServer(application)

    http_server.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()
Пример #3
0
	- 如下例所示,在[templates]下添加:

		>>> MainHandler = templates/index.html

		“=”号前面是程序内引用模板的名称。“=”号后面是模板位置。

	- 程序内引用模板示例:

		>>> self.render(TEMPLATES['MainHandler'], title="电信微信服务平台")

		模板编写方法参考:http://sebug.net/paper/books/tornado/#_5
"""

import tornado.wsgi

from wxplatform.global_settings import *
from wxplatform.logger import sm_logger
from wxplatform.WebConfigParser import WebConfigParser


sm_logger.debug("**start**")
webConfig = WebConfigParser(WEB_CONFIG_FILE)
urlPatterns = webConfig.urlPatterns()
webConfig.templates()

# 默认支持百度BAE
app = tornado.wsgi.WSGIApplication(urlPatterns)
from bae.core.wsgi import WSGIApplication
application = WSGIApplication(app)