WebashalarForML commited on
Commit
c74ee6a
·
verified ·
1 Parent(s): 54f6686

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -246,14 +246,17 @@ def create_app():
246
 
247
  @flask_app.route("/upload", methods=["POST"])
248
  def upload():
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
 
255
  # Convert the file path to an absolute path and reinitialize the agent_app
256
- abs_file_path = os.path.abspath(file_path)
257
  global agent_app
258
  agent_app = create_agent_app(abs_file_path)
259
 
 
246
 
247
  @flask_app.route("/upload", methods=["POST"])
248
  def upload():
249
+
250
+ if request.method == 'POST':
251
+ file = request.files['file']
252
+ if not file:
253
+ return "No file uploaded", 400
254
+ if file and file.filename.endswith('.db'):
255
+ db_path = os.path.join(app.config['UPLOAD_FOLDER'], 'uploaded.db')
256
+ file.save(db_path)
257
 
258
  # Convert the file path to an absolute path and reinitialize the agent_app
259
+ abs_file_path = os.path.abspath(db_path)
260
  global agent_app
261
  agent_app = create_agent_app(abs_file_path)
262