Skip to content

How can I create a Flask app that runs ComfyScript code? #64

Closed
@pranaykoppula

Description

For the life of me, I can't get this to work:

from flask import Flask, request, Response, jsonify

app = Flask(__name__)
from comfy_script.runtime import *
load(args=ComfyUIArgs('--force-fp16'))
from comfy_script.runtime.nodes import *

def comfy_function(prompt:str):
    with Workflow():
[. Some ComfyScript code ...]

@app.route("/generate",methods=['POST'])
def genimages()
    data = request.get_json()
    usr_prompt=data.get('prompt')
    res=comfy_function(usr_prompt)
    response = jsonify(res)
    return response

if __name__ == "__main__":
    app.run(host = 'X.X.X.X', port= XXXX)

I don't know what I'm doing wrong. Comfy seems to start, but when I send a request to the API, nothing happens. Is this simply not possible?

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationruntime

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions