From e9f9670eb5a0203d7fdcb25e74d96bbf65246c27 Mon Sep 17 00:00:00 2001 From: Marc-Andre Ferland Date: Sat, 15 Oct 2022 01:32:53 -0400 Subject: [PATCH] Changed '/get' from a query to a path parameter --- ui/media/main.js | 8 ++++---- ui/server.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ui/media/main.js b/ui/media/main.js index 345287ef..c585be5a 100644 --- a/ui/media/main.js +++ b/ui/media/main.js @@ -1213,7 +1213,7 @@ useBetaChannelField.addEventListener('click', async function(e) { async function getAppConfig() { try { - let res = await fetch('/get?key=app_config') + let res = await fetch('/get/app_config') const config = await res.json() if (config.update_branch === 'beta') { @@ -1229,7 +1229,7 @@ async function getAppConfig() { async function getModels() { try { - let res = await fetch('/get?key=models') + let res = await fetch('/get/models') const models = await res.json() let activeModel = models['active'] @@ -1494,7 +1494,7 @@ async function getDiskPath() { return } - let res = await fetch('/get?key=output_dir') + let res = await fetch('/get/output_dir') if (res.status === 200) { res = await res.json() res = res[0] @@ -1613,7 +1613,7 @@ function resizeModifierCards(val) { async function loadModifiers() { try { - let res = await fetch('/get?key=modifiers') + let res = await fetch('/get/modifiers') if (res.status === 200) { res = await res.json() diff --git a/ui/server.py b/ui/server.py index 3c9b9dd2..7522f234 100644 --- a/ui/server.py +++ b/ui/server.py @@ -494,19 +494,19 @@ def getModels(): return models -@app.get('/get') +@app.get('/get/{key:path}') def read_web_data(key:str=None): - if key is None: # /get without parameters, stable-diffusion easter egg. + if not key: # /get without parameters, stable-diffusion easter egg. return HTTPException(status_code=418, detail="StableDiffusion is drawing a teapot!") # HTTP418 I'm a teapot elif key == 'app_config': config = getConfig(default_val=None) if config is None: return HTTPException(status_code=500, detail="Config file is missing or unreadable") - return config + return JSONResponse(config, headers=NOCACHE_HEADERS) elif key == 'models': - return getModels() + return JSONResponse(getModels(), headers=NOCACHE_HEADERS) elif key == 'modifiers': return FileResponse(os.path.join(SD_UI_DIR, 'modifiers.json'), headers=NOCACHE_HEADERS) - elif key == 'output_dir': return {outpath} + elif key == 'output_dir': return JSONResponse({outpath}, headers=NOCACHE_HEADERS) else: return HTTPException(status_code=404, detail=f'Request for unknown {key}') # HTTP404 Not Found