def home():
    """Home page of app"""
    # Create form
    form = ReusableForm(request.form)

    # On form entry
    if request.method == 'POST':
        # Extract information
        seed = request.form['seed']
        diversity = float(request.form['diversity'])
        words = int(request.form['words'])
        # If all vadidations met
        if form.validate():
            if seed == 'random':
                return generate_output(model=model,
                                       graph=graph,
                                       new_words=words,
                                       diversity=diversity)
            else:
                return generate_from_seed(model=model,
                                          graph=graph,
                                          seed=seed,
                                          new_words=words,
                                          diversity=diversity)
    # Send template information to home.html
    return render_template('home.html', form=form)
Esempio n. 2
0
def home():
    """Home page of app with form"""

    # Create form
    form = ReusableForm(request.form)

    # On form entry and all conditions met
    if request.method == 'POST' and form.validate():
        # Extract information
        seed = request.form['seed']
        diversity = float(request.form['diversity'])
        words = int(request.form['words'])
        # Generate a random sequence
        if seed == 'random':
            return render_template('random.html',
                                   input=generate_random_start(
                                       model=model,
                                       graph=graph,
                                       new_words=words,
                                       diversity=diversity))
        # Generate starting from a seed sequence
        else:
            return render_template('seeded.html',
                                   input=generate_from_seed(
                                       model=model,
                                       graph=graph,
                                       seed=seed,
                                       new_words=words,
                                       diversity=diversity))
    # Send template information to index.html
    return render_template('index.html', form=form)
Esempio n. 3
0
def home():
    """Home page of app with form"""
    # Create form
    form = ReusableForm(request.form)

    # On form entry and all conditions met
    if request.method == 'POST' and form.validate():
        seed = request.form['seed']
        return render_template('seeded.html',
                               input=generate_from_seed(model=model,
                                                        graph=graph,
                                                        seed=seed))
    # Send template information to index.html
    return render_template('index.html', form=form)