Skip to content

Commit

Permalink
add draw endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Dec 29, 2023
1 parent ea272c7 commit d5a2afb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hayhooks/server/handlers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from hayhooks.server.handlers import deploy
from hayhooks.server.handlers import draw
from hayhooks.server.handlers import status
from hayhooks.server.handlers import undeploy


__all__ = ["deploy", "status", "undeploy"]
__all__ = ["deploy", "draw", "status", "undeploy"]
18 changes: 18 additions & 0 deletions src/hayhooks/server/handlers/draw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import tempfile
from pathlib import Path

from fastapi import HTTPException
from fastapi.responses import FileResponse
from hayhooks.server import app
from hayhooks.server.pipelines import registry


@app.get("/draw/{pipeline_name}")
async def status(pipeline_name):
pipeline = registry.get(pipeline_name)
if not pipeline:
raise HTTPException(status_code=404)

_, fpath = tempfile.mkstemp()
pipeline.draw(Path(fpath))
return FileResponse(fpath, media_type="image/png")

0 comments on commit d5a2afb

Please sign in to comment.