Skip to content

Commit

Permalink
update list index when patching the server (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
PladsElsker committed Jan 9, 2024
1 parent ebed0c4 commit 1746764
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib_comfyui/custom_extension_injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,25 @@ def patch_prompt_server_add_routes(parsed_class: ast.ClassDef, custom_scripts_pa
...
def add_routes(self):
self.user_manager.add_routes(self.routes)
self.app.add_routes(self.routes)
self.app.add_routes([
<- add code right there in the list
web.static('/', self.web_root, follow_symlinks=True),
])
for name, dir in nodes.EXTENSION_WEB_DIRS.items():
self.app.add_routes([
web.static('/extensions/' + urllib.parse.quote(name), dir, follow_symlinks=True),
])
...
"""
add_routes_ast_function = get_ast_function(parsed_class, 'add_routes')
for custom_scripts_path in custom_scripts_path_list:
code_patch = generate_prompt_server_add_routes_code_patch(custom_scripts_path)
extra_line_of_code = ast.parse(code_patch)
try:
add_routes_ast_function.body[2].value.args[0].elts[0:0] = [extra_line_of_code.body[0].value]
add_routes_ast_function.body[3].value.args[0].elts[0:0] = [extra_line_of_code.body[0].value]
except:
raise RuntimeError("Cannot patch comfyui as it is not up to date")
raise RuntimeError("ComfyUI was probably updated with breaking changes. "
"If A1111, ComfyUI and sd-webui-comfyui are up to date, "
"please notify the authors of sd-webui-comfyui.")


def generate_prompt_server_add_routes_code_patch(custom_scripts_path):
Expand Down

0 comments on commit 1746764

Please sign in to comment.