serve css from custom_nodes styles directories
This commit is contained in:
parent
f23bd87e47
commit
e93d5f9eda
15
server.py
15
server.py
|
@ -130,6 +130,16 @@ class PromptServer():
|
|||
embeddings = folder_paths.get_filename_list("embeddings")
|
||||
return web.json_response(list(map(lambda a: os.path.splitext(a)[0], embeddings)))
|
||||
|
||||
@routes.get("/styles")
|
||||
async def get_styles(request):
|
||||
styles = list()
|
||||
for name, dir in nodes.EXTENSION_STYLE_DIRS.items():
|
||||
files = glob.glob(os.path.join(glob.escape(dir), '**/*.css'), recursive=True)
|
||||
styles.extend(list(map(lambda f: "/styles/" + urllib.parse.quote(
|
||||
name) + "/" + os.path.relpath(f, dir).replace("\\", "/"), files)))
|
||||
|
||||
return web.json_response(styles)
|
||||
|
||||
@routes.get("/extensions")
|
||||
async def get_extensions(request):
|
||||
files = glob.glob(os.path.join(
|
||||
|
@ -523,6 +533,11 @@ class PromptServer():
|
|||
def add_routes(self):
|
||||
self.app.add_routes(self.routes)
|
||||
|
||||
for name, dir in nodes.EXTENSION_STYLE_DIRS.items():
|
||||
self.app.add_routes([
|
||||
web.static('/styles/' + urllib.parse.quote(name), dir, 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),
|
||||
|
|
Loading…
Reference in New Issue