How to list a word’s paragrams using Python on a basic HTML page

import itertools
from flask import Flask, request, render_template

app = Flask(__name__)

def find_paragrams(word: str) -> list:
    '''Returns list of word paragrams'''

    # Get permutations as list of tuples of letters
    permutations = list(itertools.permutations(word, len(word)))

    # Join tuples inside of list
    permutations = [''.join(permutation_tuple)
                    for permutation_tuple in permutations]

    # Get rid of duplicates
    permutations = list(set(permutations))

    return permutations

@app.route("/", methods=['GET', 'POST'])
def index():
    # Default value in case if an empty sting was passed into form
    params = None
    # POST request on form submit
    if request.method == 'POST':
        # Get form data
        word = request.form['paragrams']

        paragrams_list = find_paragrams(word) if word else None
        if paragrams_list:
            paragrams_count = len(paragrams_list)
            paragrams_str = ', '.join(paragrams_list)

            # Packing parametes in dict just to be clean
            params = {
                'paragrams_count': paragrams_count,
                'word': word,
                'paragrams_str': paragrams_str,
                'paragrams_list': paragrams_list

    # Render html template with jinja rendering parameters
    return render_template(

if __name__ == "__main__":'', port=8080, debug=True)


Enter a word to find its paragrams.

This is the alteration of a letter or a series of letters in a word.

{% if params %}

There are {{ params.paragrams_count }} Paragrams for "{{ params.word }}"

In string format:

{{ params.paragrams_str}}

In list format:

{{ params.paragrams_list }} {% else %}

Empty field, enter word first!

{% endif %}