diff --git a/app.py b/app.py index f2fd3081..ee9bffd7 100644 --- a/app.py +++ b/app.py @@ -28,6 +28,19 @@ from fastapi import FastAPI, Request from fastapi.responses import JSONResponse from pydantic import BaseModel, ValidationError from fastapi.encoders import jsonable_encoder +import socket +import psutil + +def get_ip_addresses(): + hostname = socket.gethostname() + ip_addresses = [socket.gethostbyname(hostname)] + + for interface_name, interface_addresses in psutil.net_if_addrs().items(): + for address in interface_addresses: + if str(address.family) == 'AddressFamily.AF_INET': + ip_addresses.append(address.address) + + return ip_addresses app = FastAPI(title="LoLLMS", description="This is the LoLLMS-Webui API documentation") @@ -64,6 +77,12 @@ if __name__ == "__main__": is_https = False # Create a Socket.IO server + if config["host"]!="localhost": + if config["host"]!="0.0.0.0": + config.allowed_origins += config["host"] + else: + config.allowed_origins += get_ip_addresses() + sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins=config.allowed_origins+[f"https://localhost:{config['port']}" if is_https else f"http://localhost:{config['port']}"], ping_timeout=1200, ping_interval=30) # Enable CORS for selected origins LOLLMSWebUI.build_instance(config=config, lollms_paths=lollms_paths, args=args, sio=sio) diff --git a/zoos/bindings_zoo b/zoos/bindings_zoo index d205fe80..f941e8d2 160000 --- a/zoos/bindings_zoo +++ b/zoos/bindings_zoo @@ -1 +1 @@ -Subproject commit d205fe80c7cb65ef0b563977592a21e71de4ad73 +Subproject commit f941e8d231533370b8786dbe2987b399498caecc