我正在写一个家庭锻炼计划,给我声音提示,什么时候切换锻炼,做什么锻炼,等等。。。我在笔记本电脑上使用一个小python程序以指定的间隔播放一些短的预录音频文件(aiff格式)。你知道吗
不过,我希望能够从我的iPhone上运行这个程序。我试图通过在我的计算机上设置一个Flask服务器来做到这一点。我可以让程序在托管服务器的同一台机器上通过web浏览器运行,但当我使用不同的计算机或iPhone时,音频仍在主机的扬声器上播放,而不是在客户端上播放。承载Flask服务器的计算机正在运行OS X 10.11.6。以下是程序的基本版本:
烧瓶Python:
app = Flask(__name__)
@app.route('/')
def index():
return render_template('rockrings_stackoverflow.html')
@app.route('/click', methods=['POST'])
def start_workout():
return workout.workout()
if __name__ == '__main__':
app.run(host='0.0.0.0',debug=True)
你知道吗训练.py地址:
def workout():
for minute in range(10):
audio_file = homedir + '/audio_files/easy_workout_minute%i.aiff' % minute
print audio_file
os.system('afplay %s' % audio_file)
你知道吗索引.html地址:
<!DOCTYPE html>
<html>
<body>
<h1>Welcome to the Hangboard Webtool! </h1>
Click the button below to start the easy workout
<br/><br/>
<form action="/click" method="post">
<button type="submit" value="Easy workout">
</form>
</body>
</html>
什么是烧瓶的正确实现(如果有的话)?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐