From ff1fb2ebb22143bbd082ee8131dfb8b9c77f6aff Mon Sep 17 00:00:00 2001 From: Zhang Muyu Date: Sat, 30 Sep 2023 16:05:03 +0800 Subject: [PATCH] feat: auto clean. --- main/distance.py | 2 +- main/main.py | 2 +- main/sa_pa.py | 2 +- server.py | 10 +++++++--- settings.py | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/main/distance.py b/main/distance.py index c59edef..50a4f99 100644 --- a/main/distance.py +++ b/main/distance.py @@ -82,7 +82,7 @@ def gen_distance(data, theme_type): save_image(dst, png_file_path) with open(png_file_path, "rb") as image_file: encoded_string = base64.b64encode(image_file.read()).decode('utf-8') - return encoded_string + return encoded_string, png_file_path if __name__ == '__main__': diff --git a/main/main.py b/main/main.py index 2cba9cc..87af7a6 100644 --- a/main/main.py +++ b/main/main.py @@ -126,7 +126,7 @@ def gen_common(data, theme_type): save_image(dst, png_file_path) with open(png_file_path, "rb") as image_file: encoded_string = base64.b64encode(image_file.read()).decode('utf-8') - return encoded_string + return encoded_string, png_file_path if __name__ == '__main__': diff --git a/main/sa_pa.py b/main/sa_pa.py index b711a5c..05dc09d 100644 --- a/main/sa_pa.py +++ b/main/sa_pa.py @@ -89,7 +89,7 @@ def gen_service(data): save_image(dst, png_file_path) with open(png_file_path, "rb") as image_file: encoded_string = base64.b64encode(image_file.read()).decode('utf-8') - return encoded_string + return encoded_string, png_file_path if __name__ == '__main__': diff --git a/server.py b/server.py index f5b7d53..c6452fc 100644 --- a/server.py +++ b/server.py @@ -6,6 +6,7 @@ from main.distance import * from main.sa_pa import * import json +import os app = Flask(__name__) @@ -15,35 +16,38 @@ CORS(app) def common(): json_data = json.loads(request.args.get('data')) theme = request.args.get('theme') - data = gen_common(json_data, theme) + data, path = gen_common(json_data, theme) res = { 'code': 0, 'image': data, } response = make_response(res) + os.remove(path) return response @app.route('/api/pov-element/distance', methods=["GET"]) def distance(): json_data = json.loads(request.args.get('data')) theme = request.args.get('theme') - data = gen_distance(json_data, theme) + data, path = gen_distance(json_data, theme) res = { 'code': 0, 'image': data, } response = make_response(res) + os.remove(path) return response @app.route('/api/pov-element/service', methods=["GET"]) def service(): json_data = json.loads(request.args.get('data')) - data = gen_service(json_data) + data, path = gen_service(json_data) res = { 'code': 0, 'image': data, } response = make_response(res) + os.remove(path) return response if __name__ == '__main__': diff --git a/settings.py b/settings.py index 173f581..ae9cea6 100644 --- a/settings.py +++ b/settings.py @@ -1,4 +1,4 @@ -SCALE = 2.0 +SCALE = 4.0 ALPHA = 1.0 # [0, 1] COLOR_WHITE = '#ffffff'