|
2 | 2 | Copyright (C) 2023 Probesys |
3 | 3 | """ |
4 | 4 |
|
5 | | -from flask import Flask,request, jsonify,after_this_request,send_file |
| 5 | +from flask import Flask,request, jsonify,after_this_request,send_file |
6 | 6 | from werkzeug.utils import secure_filename |
7 | 7 |
|
8 | 8 | import os |
|
15 | 15 | from lotemplate import statistic_open_document,clean_old_open_document |
16 | 16 |
|
17 | 17 | app = Flask(__name__) |
| 18 | +if os.getenv('LOG_LEVEL') : |
| 19 | + app.logger.setLevel(os.getenv('LOG_LEVEL')) |
| 20 | +else: |
| 21 | + app.logger.setLevel('ERROR') |
18 | 22 |
|
19 | 23 | @app.route("/", methods=['PUT', 'GET']) |
20 | 24 | def main_route(): |
@@ -111,7 +115,7 @@ def delete_tmp_file(response): |
111 | 115 | try: |
112 | 116 | os.remove(file) |
113 | 117 | except Exception: |
114 | | - print("Error delete file " + str(file)) |
| 118 | + app.logger.error("Error delete file " + str(file)) |
115 | 119 | return response |
116 | 120 | if request.headers.get('secretkey', '') != os.environ.get('SECRET_KEY', ''): |
117 | 121 | return utils.error_sim( |
@@ -142,7 +146,6 @@ def delete_tmp_file(response): |
142 | 146 | elif request.method == 'POST': |
143 | 147 | if not request.json: |
144 | 148 | return utils.error_sim('ApiError', 'missing_json', "You must provide a json in the body"), 400 |
145 | | - |
146 | 149 | file ,response = utils.fill_file(directory, file, request.json) |
147 | 150 | return response |
148 | 151 | elif request.method == 'DELETE': |
|
0 commit comments