Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Replace custom action view with DetailView
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonyte committed Nov 10, 2023
1 parent 7839e1a commit 1ff4b2a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import shlex
import subprocess

from deta_space_actions import Actions, ActionsMiddleware, Input, InputType, custom_view
from deta_space_actions import Actions, ActionsMiddleware, DetailView, Input, InputType
from deta_space_actions.actions import HandlerInput
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
Expand All @@ -14,7 +14,7 @@
app.mount("/static", StaticFiles(directory="./static"), name="static")
actions = Actions()
app.add_middleware(ActionsMiddleware, actions=actions)
CommandView = custom_view("/static/view.html")
# CommandView = custom_view("/static/view.html")


@app.get("/", response_class=HTMLResponse)
Expand Down Expand Up @@ -66,9 +66,13 @@ async def command(cmd: Command) -> Result:
),
],
)
async def command_action(payload: HandlerInput) -> CommandView:
async def command_action(payload: HandlerInput) -> DetailView:
result = await command(Command(command=payload.get("command", "")))
return CommandView(result.model_dump())
return DetailView(
text=f"{result.stdout}\n{result.stderr}",
title=f"{result.cwd}$ {result.command}",
)
# return CommandView(result.model_dump())


# TODO: output and command history using base

0 comments on commit 1ff4b2a

Please sign in to comment.