'How to pass the result of a python function to the html page where the action button was clicked (python bottle)

I have method:

@post('/home', method='post')
def myFunction():
    if(len(request.forms.get('Matrix_dimension').strip()) != 0):
    length = int(request.forms.get('Matrix_dimension').strip())
    tableRow = "<table>";
    for i in range(length):
        tableRow += "<tr>";
        for j in range(length):
            tableRow += "<td>";
            tableRow += "<input type=\"int\" max = \"1\" maxlength = \"1\"/>";
            tableRow += "</td>";
            tableRow += "</tr>";
            tableRow += "</table>"
    else:
        tableRow = "Enter value"
    return tableRow;

And when I click on the button, I need to draw a matrix of a certain dimension in order to receive user data from it in the future

<form action="/home" method="post"> <p><input class="text-field__input" type="int" name="Matrix_dimension" id="Matrix_dimension1" autofocus min = "2" max = "10" maxlength = "2"/> </p> <p>\<input type="submit" value="Send">\</p> <output name="result">\</output> </form>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source