Interaction-without-Interac.../client/main.py

40 lines
577 B
Python
Raw Normal View History

from flask import Flask, request
import os
import simpleaudio as sa
app = Flask(__name__)
p = None
2019-06-10 11:54:58 +00:00
w = sa.WaveObject.from_wave_file("./rave.wav")
playing = False
@app.route('/play')
def index():
2019-06-10 11:54:58 +00:00
global playing, p, w
if playing:
return 406
2019-06-10 11:54:58 +00:00
else:
playing = True
p = w.play()
return 200
@app.route('/stop')
def test():
2019-06-10 11:54:58 +00:00
global playing, p
if playing:
return 200
2019-06-10 11:54:58 +00:00
else:
playing = False
p.stop()
return 406
2019-06-10 11:54:58 +00:00
port = int(os.environ.get('PORT', 81))
app.run(host='0.0.0.0', port=port)