0

I'm generating an HTML page via Python, using the Flask framework to receive messages and the requests module to send them. My python script has a global list variable called History, and when a button is clicked I want the python script to run the command History = [] (e.g. dump the contents of the list).

How do i achieve that? I generated the button with the following code :

s += '<input type="submit" value="Reset History">'
return s

But right now it does nothing.

0

1 Answer 1

4

Have the HTML page send a value using either POST or GET, which is then picked up by a cgi form in Python, converted to integer, and

<input type="submit" name="reset_hist" />

if(reset_hist):
    History = []

Or you could use AJAX to send the request, instead of loading a new page. see xmlHttpRequest()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.