Esempio n. 1
0
"""
A WSGI application entry.
"""
import sys

import os

# 模块自己的PYTHON_PATH, 让代码找到正确的tools_lib. =>要在所有import前做!!!
sys.path.insert(
    0,
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)))

from tools_lib.common_util.log import init_log
# 配置全局logging. => 配完PYTHON_PATH,在所有的import前做!!!
init_log(os.path.dirname(os.path.abspath(__file__)))

from tools_lib.transwarp.web import WSGIApplication
import rest_api

WSGI_APP = WSGIApplication(os.path.dirname(os.path.abspath(__file__)))

WSGI_APP.add_module(rest_api)

if __name__ == '__main__':
    WSGI_APP.run(4002, host='0.0.0.0')
else:
    # init log does not work here.
    print("\n@@@ uWSGI @@@\n")
    application = WSGI_APP.get_wsgi_application()
Esempio n. 2
0
#!/usr/bin/env python
# coding:utf-8
from __future__ import unicode_literals
import os
import sys

# 模块自己的PYTHON_PATH, 让代码找到正确的tools_lib. =>要在所有import前做!!!
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)))

from tools_lib.common_util.log import init_log

# 配置全局logging. => 配完PYTHON_PATH,在所有的import前做!!!
init_log(os.path.dirname(os.path.abspath(__file__)))

import logging
import tornado.ioloop
import tornado.web
import tornado.websocket
import tornado.httpserver
from tornado.options import define, options, parse_command_line

from tools_lib.host_info import DEBUG
from handlers import normal, websocket

urls = [
    (r'/', normal.IndexHandler),
    (r'/web_socket', websocket.WebSocketHandler),
]


class Application(tornado.web.Application):