中文readme
Simple ComfyUI backend WebSocket API wrapper
Simple frontend + RESTful API backend
Features:
- REST API
- User management
- Simple FIFO scheduler
- Keep images from ComfyUI output
- Comfyui separate network
- Easy and simple logic
- 2 examples for text input and image input
Lightweight Flask framework.
User credentials are stored in a JSON file:
{
"users": {
"user1": "password1",
"user2": "password2"
}
}- Each user is allowed only one running instance.
- If another user is executing, the request will be queued and return the queue number.
- There is no queue monitoring code; you need to implement your own monitoring logic in the frontend.
- Results are cached. Subsequent submissions will be ignored, and the result will be fetched from the cache.
data: This directory stores the ComfyUI API workflows.uploads: This directory stores user-uploaded images.comfyui_img: This directory stores images generated by ComfyUI.
Two examples are provided for text input and image input.
-
Create a virtual environment:
python -m venv venv source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Update configuration:
- Set
COMFYUI_SERVER_ADDRESS = "127.0.0.1:8188" - Set
FLASK_ADDR = 'http://127.0.0.1:5000'
- Set
please img preview as image output

-
Copy the workflow API file into the
datadirectory. -
Create a new route in the Flask app:
@app.route('/api/new_api', methods=['POST']) -
Load/overwrite values and fill the task:
(prompt, ret,) = get_promp_from_json('api_test.json') data = request.get_json() text = data.get('text') task['prompt'] = prompt task['text'] = text task['call'] = api1
-
Define the API function:
def api1(task): # t2i, input: text prompt = task['prompt'] prompt['42']['inputs']['text'] = task['text'] output_images = process_comfyui(prompt) (p,) = save_img_result("comfyui_img", "t2i", output_images[0]) #output_image array is all output image_preview return f"{FLASK_ADDR}/{p}"
-
Follow this template to add new workflows.
Happy hacking! 🚀




