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")
|
embeddings = folder_paths.get_filename_list("embeddings")
|
||||||
return web.json_response(list(map(lambda a: os.path.splitext(a)[0], 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")
|
@routes.get("/extensions")
|
||||||
async def get_extensions(request):
|
async def get_extensions(request):
|
||||||
files = glob.glob(os.path.join(
|
files = glob.glob(os.path.join(
|
||||||
|
@ -523,6 +533,11 @@ class PromptServer():
|
||||||
def add_routes(self):
|
def add_routes(self):
|
||||||
self.app.add_routes(self.routes)
|
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():
|
for name, dir in nodes.EXTENSION_WEB_DIRS.items():
|
||||||
self.app.add_routes([
|
self.app.add_routes([
|
||||||
web.static('/extensions/' + urllib.parse.quote(name), dir, follow_symlinks=True),
|
web.static('/extensions/' + urllib.parse.quote(name), dir, follow_symlinks=True),
|
||||||
|
|
Loading…
Reference in New Issue