Allow LAN access to LLM web server

This commit is contained in:
seo-amugae committed 2026-08-09 18:28:04 +09:00
1 parent f186af3387
commit 99455ad531
1 file changed
+7 -2
+7 -2
View File
@@ -1,6 +1,7 @@
from __future__ import annotations
import json
import socket
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path
@@ -9,6 +10,8 @@ import ollama
ROOT = Path(__file__).parent
MODEL = "qwen2.5:3b"
HOST = "0.0.0.0"
PORT = 8787
class Handler(SimpleHTTPRequestHandler):
@@ -50,8 +53,10 @@ class Handler(SimpleHTTPRequestHandler):
def main() -> None:
server = ThreadingHTTPServer(("127.0.0.1", 8787), Handler)
print("LLM web is running at http://127.0.0.1:8787")
server = ThreadingHTTPServer((HOST, PORT), Handler)
local_ip = socket.gethostbyname(socket.gethostname())
print(f"LLM web is running locally at http://127.0.0.1:{PORT}")
print(f"LAN access is available at http://{local_ip}:{PORT}")
server.serve_forever()