(self)
| 20 | |
| 21 | class Handler(BaseHTTPRequestHandler): |
| 22 | def do_GET(self): |
| 23 | if self.path == "/health": |
| 24 | self._json(200, {"status": "ok"}) |
| 25 | elif self.path == "/hello": |
| 26 | self._json(200, {"message": "hello from OpenShell sandbox!"}) |
| 27 | elif self.path.startswith("/hello/"): |
| 28 | name = self.path[len("/hello/") :] |
| 29 | self._json(200, {"message": f"hello, {name}!"}) |
| 30 | else: |
| 31 | self._json(404, {"error": "not found"}) |
| 32 | |
| 33 | def _json(self, code, body): |
| 34 | payload = json.dumps(body).encode() |