from sanic import response import logging from views import pay_bp from sanicms.server import app from sanicms.client import Client logger = logging.getLogger('sanic') # add blueprint app.blueprint(pay_bp) @app.listener('before_server_start') async def before_srver_start(app, loop): # TODO: 改为配置文件读取相关依赖应用服务 或则获取统一的服务注册中心 获取相关服务 app.user_client = Client('user-service', app=app) app.order_client = Client('order-service', app=app) @app.listener('before_server_stop') async def before_server_stop(app, loop): app.user_client.close() app.order_client.close() @app.route("/") async def index(request): return 'pay service Evankao'
import logging from sanicms.server import app from sanicms.client import Client from views import region_bp logger = logging.getLogger('sanic') app.blueprint(region_bp) @app.route('/') async def index(request): return 'region service' if __name__ == '__main__': app.run(host="0.0.0.0", port=app.config['PORT'], debug=True)
import logging from views import user_bp from sanicms.server import app logger = logging.getLogger('sanic') app.name = 'user-service' # add blueprint app.blueprint(user_bp) # @app.listener('before_server_start') # async def before_srver_start(app, loop): # app.client = Client(loop, url=USER) # # @app.listener('before_server_stop') # async def before_server_stop(app, loop): # app.client.close() @app.route("/") async def index(request): return 'Hello world' app.config.API_VERSION = '1.0.0' app.config.API_TITLE = 'USER API' app.config.API_DESCRIPTION = 'USER API' app.config.API_TERMS_OF_SERVICE = 'Use with caution!' app.config.API_PRODUCES_CONTENT_TYPES = ['application/json']
from sanic import response import logging from views import order_bp from sanicms.server import app from sanicms.client import Client logger = logging.getLogger('sanic') # add blueprint app.blueprint(order_bp) @app.listener('before_server_start') async def before_srver_start(app, loop): # TODO: 改为配置文件读取相关依赖应用服务 app.user_client = Client('user-service', app=app) @app.listener('before_server_stop') async def before_server_stop(app, loop): app.user_client.close() @app.route("/") async def index(request): return 'order service Evankao' if __name__ == '__main__': app.run(host="0.0.0.0", port=app.config['PORT'], debug=True)
import logging from sanicms.server import app from sanicms.client import Client from views import role_bp logger = logging.getLogger('sanic') app.blueprint(role_bp) @app.route('/') async def index(request): return 'role service' if __name__ == '__main__': app.run(host="0.0.0.0", port=app.config['PORT'], debug=True)
from sanic import response import logging from views import merchant_bp from sanicms.server import app from sanicms.client import Client logger = logging.getLogger('sanic') # add blueprint app.blueprint(merchant_bp) @app.listener('before_server_start') async def before_srver_start(app, loop): # TODO: 改为配置文件读取相关依赖应用服务 或则获取统一的服务注册中心 获取相关服务 app.user_client = Client('user-service', app=app) app.order_client = Client('order-service', app=app) @app.listener('before_server_stop') async def before_server_stop(app, loop): app.user_client.close() app.order_client.close() @app.route("/") async def index(request): return 'Merchant service Evankao'
from sanic import response import logging from views import commodity_bp from sanicms.server import app from sanicms.client import Client logger = logging.getLogger('sanic') # add blueprint app.blueprint(commodity_bp) @app.listener('before_server_start') async def before_srver_start(app, loop): # TODO: 改为配置文件读取相关依赖应用服务 或则获取统一的服务注册中心 获取相关服务 app.user_client = Client('user-service', app=app) # app.order_client = Client('order-service', app=app) @app.listener('before_server_stop') async def before_server_stop(app, loop): app.user_client.close() # app.order_client.close() @app.route("/") async def index(request): return 'commodity service Evankao'