Skip to content
Advertisement

flask python website save user input and add it to the list

this website currently starts out with two input fields at the tope left corner. The first input is the persons name and the second input is the question they have.Currently it just prints successful and unsuccessful. when you press submit button I want the website to print and save the name and question. when a new question is asked it gets added to the list. for example

Danny: how old are U? Tom: when’s ur birthday? Ashley : how tall are you ?

JavaScript

Advertisement

Answer

I think it may help to look into Flask templating, which would allow you to add each response to a list in python, and then re-render the webpage with the new data as shown in this example.

In app.py

JavaScript

In templates/def.html

JavaScript

In this example, each time a form is submitted, the questions variable in app.py gets appended to, and then def.html gets re-rendered with the new data.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement