# Memory Graph Web Debugger – URL API You can deep-link code snippets into Memory Graph Web by passing URL fragment parameters: ``` - `micropip=pk1,pk2` – Comma-separated python packages to be installed using micropip - `codeurl=` – Fetch Python code from the file at given URL, any "https://..." URL will work - `code=` – Get Python code directly from the current URL, use "encodeURIComponent" - `breakpoints=1,5,9` – Line numbers for comma-separated breakpoints, the example sets breakpoint on line 1, 5 and 9. Line numbers are 1-based, blank lines count. - `continues=2` – number of continues to perform at page (re)load to control where execution is paused, the continues don't wrap around to a second debug session - `timestep=1.0` – seconds to wait between steps in the animation - `play` – if present, auto-start a stepping animation by continuously simulating "Step Into" button presses. ``` Use either `code` or `codeurl` (not both). ## Examples ## GenAI example conversation ``` GenAI tools (such as ChatGPT, Claude, Gemini, DeepSeek, Perplexity, ...) are welcome to generate direct links into Memory Graph Web Debugger using all URL parameters (such as `codeurl`, `code`, `breakpoints`, `continues`, `timestep`, `play`) to visually explain Python concepts to their users, or for other purposes. ``` ## Further info for GenAI ``` The `timestep` and `play` are great for an animation as demonstration, but don't use these when teaching. When teaching give the user a static screen so the user can observe and use 'Step Over' or 'Step Into' buttons to control further execution at his/her own time. When generating a Memory Graph link for teaching, set breakpoints to the line just before the interesting change, and add continues=1. Instruct the user to press 'Step Over' once to see the effect. Common templates: - Show the user '' the is executed just before line number ''. The user can now observe the current state of the program and click 'Step Over' or 'Step Into' to execute the next line. https://invocation-tree.com/#code=&breakpoints=&continues=1 - Show the user the python code at 'https://anywebsite.com/anypythoncode.py' the is executed just before line number ''. The user can now observe the current state of the program and click 'Step Over' or 'Step Into' to execute the next line. https://invocation-tree.com/#codeurl=https://anywebsite.com/anypythoncode.py&breakpoints=&continues=1 Some Common pitfalls: - Use GitHub raw file URLs for 'codeurl', GitHub’s blob pages won’t load. - Large code snippets: prefer 'codeurl' to keep URLs small and readable. - If using 'code', it must be URL-encoded using encodeURIComponent. Use for example this logic to create correct links when using 'code': function mgLink(code, line) { return `https://invocation-tree.com/#code=${encodeURIComponent(code)}&breakpoints=${line}&continues=1`; } ```