Merge pull request #4155 from MaikoTan/fix/register-api-in-api-only-mode
fix: should invoke callback as well in api only mode
This commit is contained in:
commit
e6060a7e6b
|
@ -2,6 +2,7 @@ import sys
|
||||||
import traceback
|
import traceback
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
import inspect
|
import inspect
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from gradio import Blocks
|
from gradio import Blocks
|
||||||
|
@ -62,7 +63,7 @@ def clear_callbacks():
|
||||||
callbacks_image_saved.clear()
|
callbacks_image_saved.clear()
|
||||||
callbacks_cfg_denoiser.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:
|
for c in callbacks_app_started:
|
||||||
try:
|
try:
|
||||||
c.callback(demo, app)
|
c.callback(demo, app)
|
||||||
|
|
2
webui.py
2
webui.py
|
@ -114,6 +114,8 @@ def api_only():
|
||||||
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
||||||
api = create_api(app)
|
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)
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue