oc_chat
Loading...
Searching...
No Matches
launch.py
Go to the documentation of this file.
1
import
http.server
2
import
os
3
import
socketserver
4
import
sys
5
import
webbrowser
6
7
PORT = 8000
8
PAGE =
"ollama-chat.html"
9
10
os.chdir(os.path.dirname(os.path.abspath(__file__)))
11
12
url = f
"http://localhost:{PORT}/{PAGE}"
13
14
class
QuietHandler
(http.server.SimpleHTTPRequestHandler):
15
def
log_message
(self, fmt, *args):
16
pass
17
18
try
:
19
with
socketserver.TCPServer((
""
, PORT), QuietHandler)
as
httpd:
20
print(f
"Serving {PAGE} at {url}"
)
21
print(
"Press Ctrl+C to stop."
)
22
webbrowser.open_new_tab(url)
23
httpd.serve_forever()
24
except
KeyboardInterrupt:
25
print(
"\nStopped."
)
26
sys.exit(0)
27
except
OSError
as
e:
28
print(f
"Could not start server on port {PORT}: {e}"
)
29
sys.exit(1)
launch.QuietHandler
Definition
launch.py:14
launch.QuietHandler.log_message
log_message(self, fmt, *args)
Definition
launch.py:15
http.server
oc_chat
docs
Ollama
launch.py
Generated by
1.15.0