mardi 28 février 2017

How to send back as a response to a request an html file through this python code? I run this server on my raspberry pi

import socket
ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ms.bind(('', 8080))
ms.listen(5)
conn, addr = ms.accept()
while True:
        data = conn.recv(1000)
        if not data:
                break
        print("Got Request")
conn.close()
ms.close()

What command should I add in order to send as a response to the request a file called hello.html. I have saved the file in the same location as the server.py file.




Aucun commentaire:

Enregistrer un commentaire