fix: should invoke callback as well in api only mode

This commit is contained in:
Maiko Tan 2022-11-02 15:04:35 +08:00
parent 95c6308ccd
commit dd2108fdac
No known key found for this signature in database
GPG key ID: 0F3B49C721E5F453
2 changed files with 4 additions and 1 deletions

View file

@ -2,6 +2,7 @@ import sys
import traceback
from collections import namedtuple
import inspect
from typing import Optional
from fastapi import FastAPI
from gradio import Blocks
@ -62,7 +63,7 @@ def clear_callbacks():
callbacks_image_saved.clear()
callbacks_cfg_denoiser.clear()
def app_started_callback(demo: Blocks, app: FastAPI):
def app_started_callback(demo: Optional[Blocks], app: FastAPI):
for c in callbacks_app_started:
try:
c.callback(demo, app)

View file

@ -114,6 +114,8 @@ def api_only():
app.add_middleware(GZipMiddleware, minimum_size=1000)
api = create_api(app)
modules.script_callbacks.app_started_callback(None, app)
api.launch(server_name="0.0.0.0" if cmd_opts.listen else "127.0.0.1", port=cmd_opts.port if cmd_opts.port else 7861)