summaryrefslogtreecommitdiff
path: root/app.py
blob: 32c1237e608d114be9e8e6d7dd9cc9a5d9930a73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import ast
from flask import Flask, render_template, request
from constants import chords
from generate_chord_tones import ChordToneGenerator


app = Flask(__name__)


@app.route('/', methods=('GET', 'POST'))
def index():
    chord_map = None
    counts = None
    if request.method == 'POST':
        selected_chords = []
        for chord in request.form:
            current_chord = request.form.get(chord)
            if current_chord:
                selected_chords.append(current_chord)

        if selected_chords:
            generator = ChordToneGenerator(selected_chords)
            generator.main()
            chord_map = generator.prepped_chord_map
            counts = generator.counts

    return render_template('index.html', chords=chords, chord_map=chord_map, counts=counts)