diff options
| author | Dan Davison <dandavison7@gmail.com> | 2024-08-20 10:33:09 -0400 |
|---|---|---|
| committer | Dan Davison <dandavison7@gmail.com> | 2024-08-20 10:33:09 -0400 |
| commit | 07f12c7cd1a1a20822331716d858c9e41a87e3e3 (patch) | |
| tree | 59d9bdeb008317fda54d42de8ff1c770b65511e5 | |
| parent | 977767a6c8e710684cd04c470c5c62de12a58861 (diff) | |
Tweak Python server example
| -rw-r--r-- | manual/src/hyperlinks.md | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/manual/src/hyperlinks.md b/manual/src/hyperlinks.md index 6b33df6..bfd6a2a 100644 --- a/manual/src/hyperlinks.md +++ b/manual/src/hyperlinks.md @@ -36,6 +36,7 @@ If your editor does not have its own URL protocol, then there are still many pos Here's some Python code that could be used as a starting point: ```python from http.server import BaseHTTPRequestHandler, HTTPServer + from pathlib import Path from subprocess import call from urllib.parse import parse_qs, urlparse @@ -44,8 +45,10 @@ If your editor does not have its own URL protocol, then there are still many pos if self.path.startswith("/open-in-editor"): query = parse_qs(urlparse(self.path).query) [path], [line] = query["path"], query["line"] - # Replace with the right command for your editor - call(["code", "-g", f"{path}:{line}"]) + # TODO: Replace with the appropriate command for your editor + cwd = Path(path).parent + print("cwd", cwd) + call(["code", "-g", f"{path}:{line}"], cwd=cwd) self.send_response(200) else: self.send_response(404) |
