Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -243,20 +243,21 @@ def create_app():
|
|
| 243 |
thread.start()
|
| 244 |
return "OK", 200
|
| 245 |
|
| 246 |
-
@flask_app.route("/upload", methods=["
|
| 247 |
def upload():
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
return
|
|
|
|
| 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 |
|