@app.route('/turn/<switch>', methods=['POST'])
def turn(switch):
    on = (request.form['cmd'] == 'on')
    details = {}
    if turnSwitch(switch, on):
        now = datetime.datetime.now()
        timeString = now.strftime('%Y-%m-%d %H:%M')
        details.update({'time': timeString})
    return jsonify(**details)
@app.route('/turn/<switch>', methods=['POST'])
def turn(switch):
    on = (request.form['cmd'] == 'on')
    details = {}
    if turnSwitch(switch, on):
        now = datetime.datetime.now()
        timeString = now.strftime('%Y-%m-%d %H:%M')
        details.update({'time': timeString})
    return jsonify(**details)