diff --git a/app.properties b/app.properties index c921a27918d00b6e7ac3089c5039f6191b389923..43374cb75e85d7cf7cc88217c632450e7b69fe3a 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 3fd6a9b21911afb0747eec72f691914073129085..1359eefa9931c8dfb96fe842646d168650140ac2 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 02f0c865ca3cb8e4b257cf03d695295156426138..db8644ffa93fdef1ce3f93a61dbfd68a9eb8e7b9 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 53ffa9995025ffa64e5bb8f1deb3f1c37635d768..aa8d5eea66facf4ee740923c93dd478c47b41783 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)