add internal /folder_paths route (#4980)

returns a json maps of folder paths
This commit is contained in:
Alex "mcmonkey" Goodwin 2024-09-19 22:52:55 +09:00 committed by GitHub
parent 68bb885d22
commit 3326bdfd4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -1,6 +1,6 @@
from aiohttp import web from aiohttp import web
from typing import Optional from typing import Optional
from folder_paths import models_dir, user_directory, output_directory from folder_paths import models_dir, user_directory, output_directory, folder_names_and_paths
from api_server.services.file_service import FileService from api_server.services.file_service import FileService
import app.logger import app.logger
@ -36,6 +36,13 @@ class InternalRoutes:
async def get_logs(request): async def get_logs(request):
return web.json_response(app.logger.get_logs()) return web.json_response(app.logger.get_logs())
@self.routes.get('/folder_paths')
async def get_folder_paths(request):
response = {}
for key in folder_names_and_paths:
response[key] = folder_names_and_paths[key][0]
return web.json_response(response)
def get_app(self): def get_app(self):
if self._app is None: if self._app is None:
self._app = web.Application() self._app = web.Application()