()
| 216 | |
| 217 | if not os.path.exists(file_path): |
| 218 | return jsonify({"error": "File not found"}), 404 |
| 219 | |
| 220 | # Remove the file from the filesystem |
| 221 | os.remove(file_path) |
| 222 | |
| 223 | delete_count = raghelper.retriever.delete([file_path]) |
| 224 | |
| 225 | return jsonify({"count": delete_count}) |
| 226 | |
| 227 | @app.route("/add_document", methods=['POST']) |
| 228 | def add_document(): |
| 229 | if 'file' not in request.files: |
| 230 | return jsonify({"error": "No file part in the request"}), 400 |
| 231 | |
| 232 | dataset = request.form.get('dataset') |
| 233 | if not dataset: |
| 234 | return jsonify({"error": "No dataset in the request"}), 400 |
| 235 | |
| 236 | file = request.files['file'] |
| 237 | if file.filename == '': |
| 238 | return jsonify({"error": "No file selected"}), 400 |
| 239 | |
| 240 | # Save the file to the data directory |
| 241 | file_path = os.path.join(os.getenv('data_directory'), dataset, file.filename) |
| 242 | # Create the dataset directory if it doesn't exist |
| 243 | dataset_dir = os.path.join(os.getenv('data_directory'), dataset) |
nothing calls this directly
no test coverage detected