aboutsummaryrefslogtreecommitdiff
path: root/webui.py
diff options
context:
space:
mode:
authorRyan Voots <simcop2387@simcop2387.info>2022-10-17 12:49:33 -0400
committerAUTOMATIC1111 <16777216c@gmail.com>2022-10-18 08:44:50 +0300
commitc3851a853d99ad35ccedcdd8dbeb6cfbe273439b (patch)
treeb8f8a8f42f4184a4114ac696421cabde4332c8b8 /webui.py
parentf29b16bad19b6332a15b2ef439864d866277fffb (diff)
Re-use webui fastapi application rather than requiring one or the other, not both.
Diffstat (limited to 'webui.py')
-rw-r--r--webui.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/webui.py b/webui.py
index eeee44c3..6b55fbed 100644
--- a/webui.py
+++ b/webui.py
@@ -96,14 +96,11 @@ def initialize():
def api():
- initialize()
-
from modules.api.api import Api
- api = Api()
- 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 = Api(app)
-def webui():
+def webui(launch_api=False):
initialize()
while 1:
@@ -122,6 +119,9 @@ def webui():
app.add_middleware(GZipMiddleware, minimum_size=1000)
+ if (launch_api):
+ api(app)
+
while 1:
time.sleep(0.5)
if getattr(demo, 'do_restart', False):
@@ -143,6 +143,6 @@ def webui():
if __name__ == "__main__":
if cmd_opts.api:
- api()
+ webui(True)
else:
- webui()
+ webui(False)