I am writing a very basic web server as a homework assignment and I have it running on localhost port 14000. When I browser to localhost:14000, the server sends back an HTML page with a form on it (the form’s action is the same address – localhost:14000, not sure if that’s proper or not).
Basically I want to be able to gather the data from the GET request once the page reloads after the submit – how can I do this? How can i access the stuff in the GET in general?
NOTE: I already tried socket.recv(xxx), that doesn’t work if the page is being loaded first time – in that case we are not “receiving” anything from the client so it just keeps spinning.
The secret lies in conn.recv which will give you the headers sent by the browser/client of the request. If they look like the one I generated with safari you can easily parse them (even without a complex regex pattern).