# coding:utf8 import unittest from fastweb import ioloop from fastweb import coroutine from fastweb.loader import app from fastweb.component.db.mongo import SyncMongo, AsynMongo app.load_recorder('log/app.log', system_log_path='log/sys.log', system_level='DEBUG') class SyncMongoTest(unittest.TestCase): def runTest(self): setting = {'host': 'localhost', 'db': 'local'} mongo = SyncMongo(setting).set_name('mongo_test') mongo.connect() mongo.query({'find': 'startup_log'}) mongo.print_response() # print(mongo.query('show dbs')) class AsynMongoTest(unittest.TestCase): @coroutine def q(self): setting = {'host': 'localhost', 'db': 'local', 'port': 27017}
# coding:utf8 from fastweb.loader import app from fastweb.service import start_service_server if __name__ == '__main__': app.load_recorder('service.log', system_level='DEBUG') app.load_component(layout='service', backend='ini', path='service.ini') app.load_component(layout='service', backend='ini', path='component.ini') start_service_server()
# coding:utf8 from fastweb.loader import app from fastweb.task import start_task_worker if __name__ == '__main__': app.load_recorder('task.log', system_level='DEBUG') app.load_component(layout='task', backend='ini', path='task.ini') start_task_worker()
from fastweb.web import start_server from fastweb.pattern import AsynPattern import os options.define('port', default=8085, help='this is default port', type=int) config_path = os.getcwd() + '/config.ini' options.define('config', default=config_path, help='this is default config path', type=str) if __name__ == '__main__': options.parse_command_line() app.load_recorder(os.getcwd() + '/passhub-info.log') app.load_configuration(path=options.config) app.load_component(pattern=AsynPattern) app.load_errcode() from handler.system import url as system_url from handler.otp import url as otp_url from handler.log import url as log_url from handler.api import url as api_url handlers = [] handlers[-1:-1] = system_url.Route handlers[-1:-1] = otp_url.Route handlers[-1:-1] = log_url.Route handlers[-1:-1] = api_url.Route