WebashalarForML commited on
Commit
d3da744
·
verified ·
1 Parent(s): f445716

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -10
app.py CHANGED
@@ -214,7 +214,6 @@ def upload_json_file():
214
  @app.route('/process_json', methods=['GET'])
215
  def process_json_file():
216
  try:
217
- # Get JSON folder and files
218
  json_folder = app.config['JSON_FOLDER']
219
  json_files = os.listdir(json_folder)
220
 
@@ -222,27 +221,20 @@ def process_json_file():
222
  flash('No JSON files found in the folder', 'error')
223
  return redirect(request.referrer)
224
 
225
- # Get the first JSON file (modify logic if needed)
226
- filename = json_files[0]
227
  json_path = os.path.join(json_folder, filename)
228
 
229
  if not os.path.exists(json_path):
230
  flash(f'JSON file {filename} not found', 'error')
231
  return redirect(request.referrer)
232
 
233
- print(f"Processing JSON file: {json_path}")
234
-
235
- # Process the uploaded JSON
236
  process_uploaded_json(json_path)
237
-
238
- # Save the processed data to the data folder
239
  os.makedirs(app.config['DATA_FOLDER'], exist_ok=True)
240
  processed_file_path = os.path.join(app.config['DATA_FOLDER'], f'Processed_{filename}')
241
-
242
  flash(f'JSON file {filename} processed successfully')
243
  except Exception as e:
244
  flash(f"Error processing JSON file: {str(e)}", 'error')
245
- print(f"Error: {e}")
246
 
247
  return redirect(request.referrer)
248
 
 
214
  @app.route('/process_json', methods=['GET'])
215
  def process_json_file():
216
  try:
 
217
  json_folder = app.config['JSON_FOLDER']
218
  json_files = os.listdir(json_folder)
219
 
 
221
  flash('No JSON files found in the folder', 'error')
222
  return redirect(request.referrer)
223
 
224
+ filename = json_files[0] # Modify logic if needed to handle multiple files
 
225
  json_path = os.path.join(json_folder, filename)
226
 
227
  if not os.path.exists(json_path):
228
  flash(f'JSON file {filename} not found', 'error')
229
  return redirect(request.referrer)
230
 
 
 
 
231
  process_uploaded_json(json_path)
 
 
232
  os.makedirs(app.config['DATA_FOLDER'], exist_ok=True)
233
  processed_file_path = os.path.join(app.config['DATA_FOLDER'], f'Processed_{filename}')
234
+
235
  flash(f'JSON file {filename} processed successfully')
236
  except Exception as e:
237
  flash(f"Error processing JSON file: {str(e)}", 'error')
 
238
 
239
  return redirect(request.referrer)
240