I’m writing a web server that establishes asynchronous connections and handles http requests of type TCP. For this I’m following the documentation. Below is the example of the implementation but I can’t send the HTTP request response to the client’s browser ?
# Module Name : socketserver -> https://docs.python.org/3/library/socketserver.html#module-socketserver
from socketserver import BaseRequestHandler, ThreadingTCPServer
# Class Objective :
class HTTPTCPIPv4(BaseRequestHandler):
# Method Objective :
def handle(self):
return [bytes("Welcome").encode("utf-8")]
if __name__ == "__main__":
HOST, PORT = "", 8080
# Create the asynchronous server, binding to localhost on port 8080
with ThreadingTCPServer((HOST, PORT), HTTPTCPIPv4) as server:
print("Server : Action v0.0.1, running address http://127.0.0.1:8080,")
print("cancel program with Ctrl-C")
server.serve_forever()