Allow LAN access to LLM web server
This commit is contained in:
1 parent
f186af3387
commit
99455ad531
1 file changed
+7
-2
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import socket
|
||||||
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
|
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@@ -9,6 +10,8 @@ import ollama
|
|||||||
|
|
||||||
ROOT = Path(__file__).parent
|
ROOT = Path(__file__).parent
|
||||||
MODEL = "qwen2.5:3b"
|
MODEL = "qwen2.5:3b"
|
||||||
|
HOST = "0.0.0.0"
|
||||||
|
PORT = 8787
|
||||||
|
|
||||||
|
|
||||||
class Handler(SimpleHTTPRequestHandler):
|
class Handler(SimpleHTTPRequestHandler):
|
||||||
@@ -50,8 +53,10 @@ class Handler(SimpleHTTPRequestHandler):
|
|||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
server = ThreadingHTTPServer(("127.0.0.1", 8787), Handler)
|
server = ThreadingHTTPServer((HOST, PORT), Handler)
|
||||||
print("LLM web is running at http://127.0.0.1:8787")
|
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()
|
server.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user