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)