mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-23 06:12:22 +00:00
added the lost ip address to accepted cors origins
This commit is contained in:
parent
f96fb8f263
commit
35969f6414
19
app.py
19
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)
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit d205fe80c7cb65ef0b563977592a21e71de4ad73
|
||||
Subproject commit f941e8d231533370b8786dbe2987b399498caecc
|
Loading…
Reference in New Issue
Block a user