You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-26 21:53:54 +01:00
flask tst
This commit is contained in:
@@ -11,5 +11,7 @@ class Module(PlayerModule):
|
|||||||
if track.official:
|
if track.official:
|
||||||
data = f"{track.path.name}: {format_time(elapsed)} / {format_time(total)}\n"
|
data = f"{track.path.name}: {format_time(elapsed)} / {format_time(total)}\n"
|
||||||
Path("/tmp/radioPlayer_progress").write_text(data)
|
Path("/tmp/radioPlayer_progress").write_text(data)
|
||||||
|
def shutdown(self):
|
||||||
|
Path("/tmp/radioPlayer_progress").write_text("")
|
||||||
|
|
||||||
module = Module()
|
module = Module()
|
||||||
32
modules/web.py
Normal file
32
modules/web.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import multiprocessing
|
||||||
|
|
||||||
|
from . import PlayerModule, Track
|
||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
manager = multiprocessing.Manager()
|
||||||
|
data = manager.dict()
|
||||||
|
data_lock = manager.Lock()
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.logger.disabled = True
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def home():
|
||||||
|
global data, data_lock
|
||||||
|
with data_lock: return repr(data)
|
||||||
|
|
||||||
|
def web():
|
||||||
|
app.run("0.0.0.0", 3001)
|
||||||
|
p = multiprocessing.Process(target=web)
|
||||||
|
|
||||||
|
class Module(PlayerModule):
|
||||||
|
def on_new_playlist(self, playlist: list[Track]) -> None:
|
||||||
|
global data, data_lock
|
||||||
|
with data_lock: data["playlist"] = playlist
|
||||||
|
def shutdown(self):
|
||||||
|
global p
|
||||||
|
p.terminate()
|
||||||
|
p.join()
|
||||||
|
|
||||||
|
module = Module()
|
||||||
|
p.start()
|
||||||
Reference in New Issue
Block a user