简体   繁体   中英

How to send HTTP response (not request)?

I need to send an HTTP response like the one below using python. How can this be accomplished?

HTTP/1.1 200 OK

# set up socket and connection (socket library)
while True:
    sock, addr = servSock.accept()
    sock.send("""HTTP/1.1 200 OK
Content-Type: text/html

<html><body>Hello World</body></html>
""");
    sock.close()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM