feat: add basic play/pause web ui
This commit is contained in:
18
server.py
18
server.py
@@ -1,13 +1,12 @@
|
||||
import threading
|
||||
from .generate import generate
|
||||
|
||||
# from generate import generate
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import FileResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
app = FastAPI()
|
||||
current_index = 0
|
||||
|
||||
app.mount("/", StaticFiles(directory="web", html=True), name="web")
|
||||
current_index = -1
|
||||
|
||||
|
||||
def advance():
|
||||
@@ -23,8 +22,19 @@ def advance():
|
||||
else:
|
||||
current_index = current_index + 1
|
||||
|
||||
print(f"advancing, current index {current_index}")
|
||||
|
||||
t = threading.Timer(60, advance)
|
||||
t.start()
|
||||
|
||||
|
||||
advance()
|
||||
|
||||
|
||||
@app.get("/current.mp3")
|
||||
def get_current_audio():
|
||||
print("hello")
|
||||
return FileResponse(f"{current_index}.mp3")
|
||||
|
||||
|
||||
app.mount("/", StaticFiles(directory="web", html=True), name="web")
|
||||
|
Reference in New Issue
Block a user