-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdesktop.py
More file actions
36 lines (26 loc) · 857 Bytes
/
Copy pathdesktop.py
File metadata and controls
36 lines (26 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Launch py-chat-midi as a desktop app using pywebview."""
import logging
import threading
import time
import uvicorn
import webview
from sequencer import configure_logging
logger = logging.getLogger(__name__)
def start_server():
"""Run the FastAPI server in a background thread."""
logger.info("Starting embedded server on 127.0.0.1:8000")
uvicorn.run("server:app", host="127.0.0.1", port=8000, log_level="warning")
if __name__ == "__main__":
configure_logging("WARNING")
server_thread = threading.Thread(target=start_server, daemon=True)
server_thread.start()
# Give the server a moment to start
time.sleep(1)
logger.info("Creating desktop window")
window = webview.create_window(
"py-chat-midi",
"http://127.0.0.1:8000",
width=1024,
height=768,
)
webview.start()