0

I just started experimenting connections by creating local server. I am new to this stuff.

I created a local server on my laptop via cmd:

python -m http.server

And then from my Android phone I can able to connect to my laptop via Chrome browser giving relevant IP + port and view the files. My question is from my laptop how can I disconnect my Android phone connection without stopping my server.

double-beep
  • 5,031
  • 17
  • 33
  • 41

1 Answers1

0

HTTP is stateless but browser can keep connection alive on the same TCP connection. To prevent that you should set keep_alive as false in the header of your HTTP response.

They explain about HTTP and keep-alive here : Python-Requests close http connection

You must modifiy the http header response : https://docs.python.org/3.4/library/http.server.html?highlight=exp

Victor
  • 602
  • 4
  • 12