-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
20 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |