First, I'd like to quote from the pywebio documentation:
When you encounter a design problem when using PyWebIO, you can ask yourself a question: What would I do if it is in a terminal program?
The solution in terminal program is to put the input() and put_table() into a while loop. So, in pywebio, you can do the same thing:
from pywebio.input import *
from pywebio.output import *
while True:
keyword = input()
# make some query
put_table(...)
The table will be appended to the page rather than be updated with this code. So do in terminal program. You can call pywebio.output.clear() after the input() to clear the page or use scope feature.
from pywebio.input import *
from pywebio.output import *
while True:
keyword = input()
# make some query
with use_scope('result', clear=True):
put_table(...)
When you use while True in server mode, you don't need to worry about the session will be running forever, because when you close the broswer tab, the pywebio will raise exception in your session to exit it.
In script mode, if you want to provide a way to exit the loop, you can:
from pywebio.input import *
from pywebio.output import *
while True:
keyword = input()
# make some query
with use_scope('result', clear=True):
put_table(...)
if actions("Continue?",["continue", "exit"])=="exit":
break