"""
Server for communicating with the sound module
"""

from flask import Flask, request
app = Flask(__name__)
from thread import start_new_thread
import elements as e
import audio as a


@app.route('/')
def api_root():
    return "I am working."


@app.route("/start/<tone_id>")
def api_start_loops(tone_id):
    tone_id = int(tone_id)
    start_new_thread(e.play, (a.channels[tone_id], a.songs[tone_id], tone_id))
    return


@app.route('/play/<tone_id>')
def api_play_tone(tone_id):
    a.play_channel(int(tone_id))
    e.pause[int(tone_id)] = 0
    return


@app.route('/pause/<tone_id>')
def api_pause_tone(tone_id):
    a.pause_channel(int(tone_id))
    e.pause[int(tone_id)] = 1
    return


@app.route('/beat/<tone_id>', methods=['POST'])
def api_change_beat(tone_id):
    # Change the beats per minute of given id.
    e.bpms[int(tone_id)] = int(request.form["value"])
    return


@app.route('/volume/<tone_id>', methods=['POST'])
def api_change_volume(tone_id):
    # Change the volume of given id.
    print float(request.form["value"])
    a.channels[int(tone_id)].set_volume(float(request.form["value"]))
    return


if __name__ == '__main__':
    app.run(debug=True)

"""
Server for communicating with the sound module
"""

from flask import Flask, request
app = Flask(__name__)
from thread import start_new_thread
import elements as e
import audio as a


@app.route('/')
def api_root():
    return "I am working."


@app.route("/start/<tone_id>")
def api_start_loops(tone_id):
    tone_id = int(tone_id)
    start_new_thread(e.play, (a.channels[tone_id], a.songs[tone_id], tone_id))
    return 'started playing'


@app.route('/play/<tone_id>')
def api_play_tone(tone_id):
    a.play_channel(int(tone_id))
    e.pause[int(tone_id)] = 0
    return


@app.route('/pause/<tone_id>')
def api_pause_tone(tone_id):
    a.pause_channel(int(tone_id))
    e.pause[int(tone_id)] = 1
    return


@app.route('/beat/<tone_id>', methods=['POST'])
def api_change_beat(tone_id):
    # Change the beats per minute of given id.
    e.bpms[int(tone_id)] = int(request.form["value"])
    return


@app.route('/volume/<tone_id>', methods=['POST'])
def api_change_volume(tone_id):
    # Change the volume of given id.
    print float(request.form["value"])
    a.channels[int(tone_id)].set_volume(float(request.form["value"]))
    return


if __name__ == '__main__':
    app.run(debug=True)

Add return message for /start