1

Problem is that I cannot get my image files

  1. Should I encode image files to binaryarras?
  2. How can I put use utf-8 and base64 at the same time to make image and text show up at the same time...

    ##
    import socket
    import base64
    
    server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    
    server_socket.bind(('127.0.0.1', 8080))
    
    server_socket.listen(1)
    print('listening')
    
    while True:
        connect_socket, addr = server_socket.accept()
        data = connect_socket.recv(99999)
    
        print('data received : ',data.decode())
    
        connect_socket.sendall("""HTTP/1.1 200 OK
    
        <head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
              <meta http-equiv="Content-Type" content="image/jpeg;charset=UTF-8" />
            <title>Happy pig</title>
        </head>
        <body>
           <font color=#55C0F1 size=10>
           <h1>
                "Hi"
                <img src="pig.jpg" width= "137" height="150">
           </h1>
           </font>
        </form>
        </body>
        </html>""".encode('utf-8'))
    
    connect_socket.close()
    
    ##
    
eibersji
  • 1,098
  • 1
  • 19
  • 42

0 Answers0