Skip to content

Commit

Permalink
Change response to json
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Jul 4, 2024
1 parent 5a730ab commit 868d600
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions template/server/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import uuid

from fastapi import FastAPI
from starlette.responses import JSONResponse

from messaging import JupyterKernelWebSocket
from api.models.execution import Execution
Expand All @@ -26,5 +27,6 @@ def health():


@app.post("/execute", response_model=Execution)
def execute(request: ExecutionRequest):
return ws.execute(code=request.code)
def execute(request: ExecutionRequest) -> JSONResponse:
result = ws.execute(code=request.code)
return JSONResponse(content=result)
2 changes: 1 addition & 1 deletion template/server/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(
on_stderr: Optional[Callable[[CellMessage], Any]] = None,
on_result: Optional[Callable[[Result], Any]] = None,
):
self.partial_result = Execution()
self.partial_result = Execution(results=[])
self.execution = Future()
self.on_stdout = on_stdout
self.on_stderr = on_stderr
Expand Down

0 comments on commit 868d600

Please sign in to comment.