WebashalarForML commited on
Commit
2a25020
·
verified ·
1 Parent(s): f93f1bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -243,20 +243,21 @@ def create_app():
243
  thread.start()
244
  return "OK", 200
245
 
246
- @flask_app.route("/upload", methods=["GET", "POST"])
247
  def upload():
248
- if request.method == "POST":
249
- file = request.files.get("file")
250
- if not file:
251
- return "No file uploaded", 400
252
- file_path = os.path.join(UPLOAD_FOLDER, file.filename)
253
- file.save(file_path)
254
- # Reinitialize the agent_app using the uploaded file's path.
255
- global agent_app
256
- agent_app = create_agent_app(file_path)
257
- socketio.emit("log", {"message": f"[INFO]: Database file '{file.filename}' uploaded and loaded."})
258
- return redirect(url_for("index"))
259
- return render_template("upload.html")
 
260
 
261
  return flask_app, socketio
262
 
 
243
  thread.start()
244
  return "OK", 200
245
 
246
+ @flask_app.route("/upload", methods=["POST"])
247
  def upload():
248
+ file = request.files.get("file")
249
+ if not file:
250
+ return "No file uploaded", 400
251
+ file_path = os.path.join(UPLOAD_FOLDER, file.filename)
252
+ file.save(file_path)
253
+
254
+ # Initialize new agent app using file path
255
+ global agent_app
256
+ agent_app = create_agent_app(file_path)
257
+
258
+ socketio.emit("log", {"message": f"[INFO]: Database file '{file.filename}' uploaded and loaded."})
259
+ return redirect(url_for("index")) # Go back to index page
260
+
261
 
262
  return flask_app, socketio
263