-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path__init__.py
More file actions
47 lines (36 loc) · 1.36 KB
/
__init__.py
File metadata and controls
47 lines (36 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from .ComfyUIAudioMass import NODE_CLASS_MAPPINGS
import os
import nodes
from aiohttp import web
import importlib
import execution
import logging
from pathlib import Path
import uuid
import json
import datetime
js_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "js")
nodes.EXTENSION_WEB_DIRS["ComfyUI-AudioMass"] = js_dir
__all__ = ['NODE_CLASS_MAPPINGS']
from server import PromptServer
routes = PromptServer.instance.routes
@routes.get('/audiomass')
async def serve_audiomass_index(request):
audiomass_path = Path(__file__).parent / 'audiomass-ui' / 'index.html'
if audiomass_path.exists():
return web.FileResponse(audiomass_path)
else:
return web.Response(text="AudioMass UI not found", status=404)
@routes.get('/audiomass/{path:.*}')
async def serve_audiomass_static(request):
path = request.match_info.get('path', '')
if '..' in path or path.startswith('/'):
return web.Response(text="Invalid path", status=400)
audiomass_path = Path(__file__).parent / 'audiomass-ui' / path
if audiomass_path.is_dir():
index_path = audiomass_path / 'index.html'
if index_path.exists():
return web.FileResponse(index_path)
if audiomass_path.exists() and audiomass_path.is_file():
return web.FileResponse(audiomass_path)
return web.Response(text="File not found", status=404)