|
32 | 32 |
|
33 | 33 | secret_key = os.urandom(24)
|
34 | 34 |
|
35 |
| -base_dir = os.path.dirname(os.path.abspath(__file__)) |
36 |
| -config_path = os.path.join(base_dir, "mysql_config.json") |
37 |
| -with open(config_path) as f: |
38 |
| - mysql_cred = json.load(f) |
39 |
| - |
40 |
| -conn = pymysql.connect( |
41 |
| - host=mysql_cred["servername"], |
42 |
| - user=mysql_cred["username"], |
43 |
| - password=mysql_cred["password"], |
44 |
| - db=mysql_cred["dbname"], |
45 |
| - charset="utf8mb4", |
46 |
| - cursorclass=pymysql.cursors.DictCursor, |
47 |
| - autocommit=False, |
48 |
| -) |
49 |
| - |
50 | 35 |
|
51 | 36 | @app.route("/")
|
52 | 37 | def index():
|
@@ -348,7 +333,7 @@ def fileset():
|
348 | 333 | html += "<th>Description</th>\n"
|
349 | 334 | html += "<th>Log Text</th>\n"
|
350 | 335 |
|
351 |
| - related_filesets = get_all_related_filesets(id, conn) |
| 336 | + related_filesets = get_all_related_filesets(id, connection) |
352 | 337 |
|
353 | 338 | cursor.execute(
|
354 | 339 | f"SELECT * FROM history WHERE fileset IN ({','.join(map(str, related_filesets))}) OR oldfileset IN ({','.join(map(str, related_filesets))})"
|
@@ -971,9 +956,12 @@ def validate():
|
971 | 956 | del json_response["files"]
|
972 | 957 | json_response["status"] = "no_metadata"
|
973 | 958 |
|
974 |
| - fileset_id = user_insert_fileset(json_object, ip, conn) |
| 959 | + conn = db_connect() |
| 960 | + try: |
| 961 | + fileset_id = user_insert_fileset(json_object, ip, conn) |
| 962 | + finally: |
| 963 | + conn.close() |
975 | 964 | json_response["fileset"] = fileset_id
|
976 |
| - print(f"Response: {json_response}") |
977 | 965 | return jsonify(json_response)
|
978 | 966 |
|
979 | 967 | matched_map = {}
|
|
0 commit comments