- Assuming the defaults and the sample `docker-compose.yml`,
you should be able to generate an image at `http://localhost:8000/workflows/1/image`
### Not Docker
A helper function is provided for making a dead-simple application that hosts a single workflow or directory of workflows.
Requests are proxied directly to the ComfyUI server, with no caching.
This is likely unsuitable for public use, but is the absolute fastest way to get started.
It's also almost exactly what `sample-docker-compose.yml` is doing.
```python
from comfykiosk import EasyComfyKiosk
from comfykiosk.fastapi import create_app
# Create the image generation service
comfy = EasyComfyKiosk()
# Attach FastAPI routes to it
app = create_app(comfy)
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=8000)
```
By default, it will look for workflows in a directory called `./workflows`,
or a single workflow at `./workflow.json`, but you can specify the path yourself...
```python
comfy = EasyComfyKiosk(path="./custom_workflows")
```
When a directory of workflows is loaded, their `handle` is based on the filename.
Run the app:
`python ./sample.py`
Optionally, specify where to find the ComfyUI server:
`COMFYUI_URL=127.0.0.1:8188 python ./sample.py`
Open a browser and navigate to `http://127.0.0.1:8000/workflows` to see the available workflows.
To actually generate images, navigate to `http://127.0.0.1:8000/workflows/{workflow_id}/image` or `http://127.0.0.1:8000/workflows/by-handle/{handle}/image`
## Advanced Usage
This example can be found in `sample-advanced.py` and `docker/advanced-sample-docker-compose.yml`
Let's create a webapp with a folder of workflows, and let users generate from any of them.
So they don't need to wait, we'll generate a few images from each, ahead of time.
When someone asks for a "new" image, it will be served from that buffer.
We'll also use a filesystem cache to avoid re-generating images that have already been generated.
```python
from comfykiosk import ComfyKiosk, ComfyGenerator, SimpleWorkflowLoader
from comfykiosk.image_sources.filesystem import FileSystemImageSource
from comfykiosk.image_sources.pregenerate import PreparedGenPool
from comfykiosk.fastapi import create_app
# You can compose ComfyKiosk as an alternate way to override defaults