From 5ed2c330d1be3ab7080be2b931d24b41755aff1c Mon Sep 17 00:00:00 2001 From: youhuo Date: Thu, 18 Aug 2022 19:18:03 +0800 Subject: [PATCH] fix: config --- app.properties | 7 ++----- app.py | 2 +- app/conf.py | 1 + views/common_view.py | 10 ++++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app.properties b/app.properties index c921a27..43374cb 100644 --- a/app.properties +++ b/app.properties @@ -32,8 +32,5 @@ tone_host = http://tone:7001/ tone_token = xxxx tone_user_name = xxxxx -# oss -alg_oss_access_key = xxxxxx -alg_oss_access_secret = xxxxxx -alg_oss_bucket = xxxx -alg_oss_endpoint = xxxxx \ No newline at end of file +# font +oss_url=http://0.0.0.0:8005 \ No newline at end of file diff --git a/app.py b/app.py index 3fd6a9b..1359eef 100644 --- a/app.py +++ b/app.py @@ -4,7 +4,7 @@ from app import init_app if __name__ == '__main__': app = Sanic('testlib') - app.static('/static','dist') + app.static('/static', 'dist') init_app(app) app.run(app.config['HOST'], app.config['PORT'], debug=app.config['DEBUG'], access_log=app.config['ACCESS_LOG'], workers=app.config['WORKERS'], auto_reload=app.config['AUTO_RELOAD']) diff --git a/app/conf.py b/app/conf.py index 02f0c86..db8644f 100644 --- a/app/conf.py +++ b/app/conf.py @@ -13,6 +13,7 @@ class SanicConf(object): self.config = None data = self.get_conf('app.properties') self.update_environ(data, os.environ) + app.config.update(data) self.config = app.config def get_conf(self, file_name): diff --git a/views/common_view.py b/views/common_view.py index 53ffa99..aa8d5ee 100644 --- a/views/common_view.py +++ b/views/common_view.py @@ -1,6 +1,7 @@ -from sanic import Blueprint, response, html +from sanic import Blueprint, html from sanic.exceptions import NotFound +from app.conf import conf from common.http import rsp, http_request from services.auth_service import login_auth from services.common_service import upload_static_file_to_oss @@ -18,7 +19,7 @@ async def upload_images(request, user_infos): @bp.exception(NotFound) async def ignore_404s(request, exception): - oss = 'http://0.0.0.0:8005/static' + oss = f'{conf.config["OSS_URL"]}/static' url = oss + '/index.html' _, res = await http_request(url, 'get') res = res.replace('', '') @@ -27,8 +28,9 @@ async def ignore_404s(request, exception): @bp.route('/') async def handle_request(request): - oss = 'http://0.0.0.0:8005/static' + oss = f'{conf.config["OSS_URL"]}/static' url = oss + '/index.html' _, res = await http_request(url, 'get') res = res.replace('', '') - return html(res.replace('{OPENANOLIS_TEST_LIB_TOOLS_SERVER}', oss)) + res = res.replace('{OPENANOLIS_TEST_LIB_TOOLS_SERVER}', oss) + return html(res) -- Gitee