MCPcopy
hub / github.com/pallets/werkzeug / execute_command

Method execute_command

src/werkzeug/debug/__init__.py:384–400  ·  view source on GitHub ↗

Execute a command in a console.

(
        self,
        request: Request,
        command: str,
        frame: DebugFrameSummary | _ConsoleFrame,
    )

Source from the content-addressed store, hash-verified

382 environ["wsgi.errors"].write("".join(tb.render_traceback_text()))
383
384 def execute_command(
385 self,
386 request: Request,
387 command: str,
388 frame: DebugFrameSummary | _ConsoleFrame,
389 ) -> Response:
390 """Execute a command in a console."""
391 if not self.check_host_trust(request.environ):
392 return SecurityError() # type: ignore[return-value]
393
394 contexts = self.frame_contexts.get(id(frame), [])
395
396 with ExitStack() as exit_stack:
397 for cm in contexts:
398 exit_stack.enter_context(cm)
399
400 return Response(frame.eval(command), mimetype="text/html")
401
402 def display_console(self, request: Request) -> Response:
403 """Display a standalone shell."""

Callers 1

__call__Method · 0.95

Calls 5

check_host_trustMethod · 0.95
SecurityErrorClass · 0.85
ResponseClass · 0.50
getMethod · 0.45
evalMethod · 0.45

Tested by

no test coverage detected