私は単純なサーバーを構築します:
s = socket(AF_INET, SOCK_STREAM)
s.bind(('127.0.0.1',8282))
s.listen(1)
client, info = s.accept()
request = ""
i = 0
while True:
c = client.recv(1)
request += c
if c in ["\r","\n"]:
i += 1
else:
i = 0
if i == 4:
break
print "============="
print "Client Request"
print "============="
print request
raw_input('Press Enter to send response')
data = """<html>
<body>
<h1>My Amazing Website !!!</h1>
<br>
<font color='yellow' size='20'>Hello (Name)</font>
</body>
</html>
"""
response = "HTTP/1.1 200 OK\r\n"
response += "Content-Length: %d\r\n"%len(data)
response += "Connection: Close\r\n"
response += "Content-Type: text/html\r\n\r\n"
response += data
client.send(response)
time.sleep(2)
client.close()
HTML コードの "(Name)" を URL からの get に置き換える方法がわかりません。私のURLが127.0.0.1:8282/?name=Someoneだとしましょう。ここにある「GET / * HTTP/1.1?」という名前を取得するにはどうすればよいですか?