Python webserver using tkinter button

I have created a GUI in tkinter. I want to start python-m http.server that should run forever on clicking start button and should open browser with index.html file. The server should stop on clicking close button.
later once the server has started. I want to pass values from the GUI and display result on browser.

Can anyone explain how to do it? or share a sample code

The solution (I suspect) will be OS dependent.

As a Linux user, if I were going to do this, I would (most likely) have the Python script call two bash scripts: one for starting the process and another one for halting it.

I don’t know if it would work the way you intend, but in theory, I see no reason for it not to.

caveat: untried and untested.