Retrieve a specific document from the data directory. This endpoint expects a JSON payload containing the filename of the document to retrieve. If the document exists, it is sent as a file response. Returns: JSON response with the error message and HTTP status code 404 if
()
| 164 | 'X-Accel-Buffering': 'no', |
| 165 | 'Connection': 'keep-alive', |
| 166 | }) |
| 167 | |
| 168 | @app.route("/get_documents", methods=['GET']) |
| 169 | def get_documents(): |
| 170 | # Query the database for all documents |
| 171 | files = raghelper.retriever.get_all_document_names() |
| 172 | return jsonify(files) |
| 173 | |
| 174 | |
| 175 | @app.route("/get_document", methods=['POST']) |
| 176 | def get_document(): |
| 177 | """ |
| 178 | Retrieve a specific document from the data directory. |
| 179 | |
| 180 | This endpoint expects a JSON payload containing the filename of the document to retrieve. |
| 181 | If the document exists, it is sent as a file response. |
| 182 | |
| 183 | Returns: |
| 184 | JSON response with the error message and HTTP status code 404 if not found, |
| 185 | otherwise sends the file as an attachment. |
| 186 | """ |
| 187 | json_data = request.get_json() |
| 188 | filename = json_data.get('filename') |
| 189 | data_dir = os.getenv('data_directory') |
| 190 | file_path = os.path.join(data_dir, filename) |
| 191 |
nothing calls this directly
no outgoing calls
no test coverage detected