ArtVentureX / sd-webui-agent-scheduler

619 stars 63 forks source link

How to get the value returned by the callback result? #110

Closed Bruce337f closed 1 year ago

Bruce337f commented 1 year ago

I want to deploy callbacl_url on the local server, such as http://localhost.port/task_completed, and get the result value generated by it through other interfaces of the local server, but it just prints the result on the cmd panel, what is good Suggestion?

This is a great project and it helped me a lot!

artventuredev commented 1 year ago

What language are you implementing the backend? You can checkout the README for a python example

    @app.post("/recipe/sd-tasks/upload")
    async def create_upload_files(
        files: Optional[List[UploadFile]] = File(None),
        folder_id: Annotated[str, Form(alias="folderId")] = None,
    ):
        print(f"Received {len(files)} files to folder {folder_id}")
        for file in files:
            if not file.content_type.startswith("image/"):
                raise HTTPException(status_code=400, detail="Only image files are allowed")

            print(f"* {file.filename} {file.content_type} {file.size}")
            # convert to PIL image
            # need: from PIL import Image
            img = Image.open(io.BytesIO(file.file.read()))

            # or save to disk
            save_path = os.path.join(upload_dir , file.filename) # need upload_dir predefined
            with open(file.filename, "wb") as f:
                f.write(file.file.read())
Bruce337f commented 1 year ago

Thanks for your reply and hard work on the project, I will try it again! !