forked from open-webui/open-webui
feat: allow enabling after url is provided
This commit is contained in:
parent
d863e7e60b
commit
797ed9ac7f
2 changed files with 13 additions and 4 deletions
|
@ -43,8 +43,12 @@ async def get_enable_status(request: Request, user=Depends(get_admin_user)):
|
||||||
|
|
||||||
@app.get("/enabled/toggle", response_model=bool)
|
@app.get("/enabled/toggle", response_model=bool)
|
||||||
async def toggle_enabled(request: Request, user=Depends(get_admin_user)):
|
async def toggle_enabled(request: Request, user=Depends(get_admin_user)):
|
||||||
|
try:
|
||||||
|
r = requests.head(app.state.AUTOMATIC1111_BASE_URL)
|
||||||
app.state.ENABLED = not app.state.ENABLED
|
app.state.ENABLED = not app.state.ENABLED
|
||||||
return app.state.ENABLED
|
return app.state.ENABLED
|
||||||
|
except Exception as e:
|
||||||
|
raise HTTPException(status_code=r.status_code, detail=ERROR_MESSAGES.DEFAULT(e))
|
||||||
|
|
||||||
|
|
||||||
class UrlUpdateForm(BaseModel):
|
class UrlUpdateForm(BaseModel):
|
||||||
|
|
|
@ -45,8 +45,13 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleImageGeneration = async () => {
|
const toggleImageGeneration = async () => {
|
||||||
|
if (AUTOMATIC1111_BASE_URL) {
|
||||||
enableImageGeneration = await toggleImageGenerationEnabledStatus(localStorage.token);
|
enableImageGeneration = await toggleImageGenerationEnabledStatus(localStorage.token);
|
||||||
config.set(await getBackendConfig(localStorage.token));
|
config.set(await getBackendConfig(localStorage.token));
|
||||||
|
} else {
|
||||||
|
enableImageGeneration = false;
|
||||||
|
toast.error('AUTOMATIC1111_BASE_URL not provided');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
|
Loading…
Reference in a new issue