02 web应用程序
简单的web服务器
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
import socket sock=socket.socket() sock.bind(("127.0.0.1",8080)) sock.listen(5) while True: conn,addr=sock.accept() print(addr) data=conn.recv(1024) print(data) conn.send(b"HTTP/1.1 300 OK\r\n\r\nhello,world") conn.close()
- 响应头和响应体一定要用两个换行分开