added client

going to delete other dedicated repo
This commit is contained in:
Patrice 2019-06-08 11:17:21 +02:00
parent 6b0856095d
commit 02f15a64e9
4 changed files with 53 additions and 0 deletions

1
client/README.md Normal file
View File

@ -0,0 +1 @@
UI-Client

52
client/main.py Normal file
View File

@ -0,0 +1,52 @@
from flask import Flask, request
import os
import simpleaudio as sa
#----------------------------------------------------------------------------#
# App Config.
#----------------------------------------------------------------------------#
app = Flask(__name__)
#----------------------------------------------------------------------------#
# Controllers.
#----------------------------------------------------------------------------#
p = None
w = None
playing = False
@app.route('/play')
def index():
global p, playing
playing = True
print("yes")
p = w.play()
if playing:
return 406
if not playing:
return 200
@app.route('/stop')
def test():
global p, playing
playing = False
p.stop()
if playing:
return 200
if not playing:
return 406
if __name__ == '__main__':
port = int(os.environ.get('PORT', 80))
global p
global w
w = sa.WaveObject.from_wave_file("./rave.wav")
app.run(host='0.0.0.0', port=port)

BIN
client/rave.mp3 Normal file

Binary file not shown.

BIN
client/rave.wav Normal file

Binary file not shown.