Hi, We'll create a basic http server with using socket module in Python. You dont need detailed explanation. If you are curios, research about socket module
You made it if you see "Hello Darling!" text when you connect over browser to listening IP and 80 port. You dont need to Apache Server anymore. You created your own Apache server . It was joke . But you created a basic http server. You can make better it with good ideas.
Kod:
import socket
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((socket.gethostname(), 80))
server.listen(5)
print ("{}:{} Listening...".format(*server.getsockname()))
while True:
client, address = server.accept()
print("{}:{} Connected".format(*address))
client.send(str.encode("HTTP/1.1 200 OK\n"
+"Content-Type: text/html\n"
+"\n"
+"<html><body>Hello Darling!</body></html>"))
client.close()
server.close()
You made it if you see "Hello Darling!" text when you connect over browser to listening IP and 80 port. You dont need to Apache Server anymore. You created your own Apache server . It was joke . But you created a basic http server. You can make better it with good ideas.
Moderatör tarafında düzenlendi: