Jelajahi Sumber

api only subpath (rootpath)

Co-Authored-By: 陈杰 <pythias@gmail.com>
w-e-w 2 tahun lalu
induk
melakukan
b1a16a298c
2 mengubah file dengan 3 tambahan dan 3 penghapusan
  1. 2 2
      modules/api/api.py
  2. 1 1
      webui.py

+ 2 - 2
modules/api/api.py

@@ -724,9 +724,9 @@ class Api:
             cuda = {'error': f'{err}'}
         return models.MemoryResponse(ram=ram, cuda=cuda)
 
-    def launch(self, server_name, port):
+    def launch(self, server_name, port, root_path):
         self.app.include_router(self.router)
-        uvicorn.run(self.app, host=server_name, port=port, timeout_keep_alive=shared.cmd_opts.timeout_keep_alive)
+        uvicorn.run(self.app, host=server_name, port=port, timeout_keep_alive=shared.cmd_opts.timeout_keep_alive, root_path=root_path)
 
     def kill_webui(self):
         restart.stop_program()

+ 1 - 1
webui.py

@@ -374,7 +374,7 @@ def api_only():
     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,
-        root_path = f"/{cmd_opts.subpath}"
+        root_path=f"/{cmd_opts.subpath}" if cmd_opts.subpath else ""
     )