from flask import Flask, request, render_template
from flask_debugtoolbar import DebugToolbarExtension
from stories import story 


app = Flask(__name__)
app.config['SECRET_KEY'] = 'oh-so-secret'

debug = DebugToolbarExtension(app)

@app.route('/')
def collect_form_inputs():
    '''Display form that asks the user to enter words for the mad lib. The labels for the form are generated by the instance of the story class currently selected/in use'''
    prompt_list = [prompt for prompt in story.prompts]
    return render_template('questions.html', prompts = prompt_list)



@app.route('/story')
def generate_story():
    '''Generates a story with the words the user in the MadLibs form. Displays the finished story in story.html'''
    finished_story = story.generate(request.args)
    return render_template('story.html', story=finished_story)