MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / load_log

Function load_log

codeclash/viewer/app.py:1255–1289  ·  view source on GitHub ↗

Load log file content on demand

()

Source from the content-addressed store, hash-verified

1253
1254@app.route("/load-log")
1255def load_log():
1256 """Load log file content on demand"""
1257 # Don't allow log loading in static mode - skip freezing
1258 if STATIC_MODE:
1259 return redirect(url_for("index"))
1260
1261 file_path = request.args.get("path")
1262
1263 if not file_path:
1264 return jsonify({"success": False, "error": "No file path provided"}), 400
1265
1266 try:
1267 # Convert to Path object
1268 file_path_obj = Path(file_path)
1269
1270 # Security check: ensure the file exists
1271 if not file_path_obj.exists():
1272 return jsonify({"success": False, "error": "File does not exist"}), 404
1273
1274 # Security check: ensure the file is not a directory
1275 if not file_path_obj.is_file():
1276 return jsonify({"success": False, "error": "Path is not a file"}), 400
1277
1278 # Security check: ensure the path is within our expected logs directory
1279 try:
1280 file_path_obj.relative_to(LOG_BASE_DIR)
1281 except ValueError:
1282 return jsonify({"success": False, "error": "Invalid file path"}), 403
1283
1284 # Read and return the file content
1285 content = file_path_obj.read_text()
1286 return jsonify({"success": True, "content": content})
1287
1288 except (OSError, UnicodeDecodeError) as e:
1289 return jsonify({"success": False, "error": f"Error reading file: {str(e)}"}), 500
1290
1291
1292@app.route("/load-trajectory-details")

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected