This commit is contained in:
lda
2026-08-30 05:53:43 +07:00 Verified
parent 1cdf822825
commit db1c344e0f
6 changed files with 1100 additions and 3 deletions
+13 -3
View File
@@ -39,7 +39,9 @@ def get_shell(shell_name: str):
@app.post("/shells/{shell_name}/run")
def run_code(
shell_name: Annotated[str, Path(..., description="The shell to run code in")],
code: Annotated[str, Body(..., description="The code to execute", media_type="text/plain")],
code: Annotated[
str, Body(..., description="The code to execute", media_type="text/plain")
],
options: Annotated[CallOptions, Depends()],
):
return ShellApp.run_code(code, shell_name, options=options)
@@ -47,13 +49,21 @@ def run_code(
@app.post("/run")
def run_code_2(
code: Annotated[str, Body(..., description="The code to execute", media_type="text/plain")],
code: Annotated[
str, Body(..., description="The code to execute", media_type="text/plain")
],
options: Annotated[CallOptions, Depends()],
shell_name: Annotated[str, Query(description="The shell to run code in")] = "last",
):
return ShellApp.run_code(code, shell_name, options=options)
if __name__ == "__main__":
def main() -> None:
"""Run the HTTP API with Uvicorn."""
import uvicorn
uvicorn.run(app, host="::", port=8000, log_level="info")
if __name__ == "__main__":
main()