Skip to content

Commit

Permalink
feat: preview method endpoint
Browse files Browse the repository at this point in the history
* post method `/preview_method` is added

comfyanonymous#6205
  • Loading branch information
ltdrdata committed Dec 29, 2024
1 parent a618f76 commit c3cc84f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from app.custom_node_manager import CustomNodeManager
from typing import Optional
from api_server.routes.internal.internal_routes import InternalRoutes
import latent_preview

class BinaryEventTypes:
PREVIEW_IMAGE = 1
Expand Down Expand Up @@ -692,6 +693,26 @@ async def post_history(request):

return web.Response(status=200)

@routes.post("/preview_method")
async def preview_method(request):
json_data = await request.json()

if "value" in json_data:
method = json_data['value']

if method == 'auto':
args.preview_method = latent_preview.LatentPreviewMethod.Auto
elif method == 'latent2rgb':
args.preview_method = latent_preview.LatentPreviewMethod.Latent2RGB
elif method == 'taesd':
args.preview_method = latent_preview.LatentPreviewMethod.TAESD
else:
args.preview_method = latent_preview.LatentPreviewMethod.NoPreviews

return web.Response(status=200)

return web.Response(status=400)

async def setup(self):
timeout = aiohttp.ClientTimeout(total=None) # no timeout
self.client_session = aiohttp.ClientSession(timeout=timeout)
Expand Down

0 comments on commit c3cc84f

Please sign in to comment.