import socket
import sys

# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('localhost', 10000)
sock.bind(('127.0.0.1',8080))
sock.listen(10)
optional_headers=('''Content-Length: 55743
Connection: keep-alive
Cache-Control: s-maxage=300, public, max-age=0
Content-Language: en-US
Date: Thu, 06 Dec 2018 17:37:18 GMT
ETag: "2e77ad1dc6ab0b53a2996dfd4653c1c3"
Server: meinheld/0.6.1
Strict-Transport-Security: max-age=63072000
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Vary: Accept-Encoding,Cookie
Age: 7
''')
response=('''
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8




<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>A simple webpage</title>
</head>
<body>
  <h1>Simple HTML5 webpage</h1>
  <p>Hello, world!</p>
</body>
</html>
''')
while True:
    connection, addr = sock.accept()
    print('conn:',connection,'addr',addr,'recv',connection.recv(1600))
    connection.sendall(bytes(response,'utf-8'))
    

import socket
import sys

# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('localhost', 10000)
sock.bind(('127.0.0.1',8080))
sock.listen(10)
optional_headers=('''Content-Length: 55743
Connection: keep-alive
Cache-Control: s-maxage=300, public, max-age=0
Content-Language: en-US
Date: Thu, 06 Dec 2018 17:37:18 GMT
ETag: "2e77ad1dc6ab0b53a2996dfd4653c1c3"
Server: meinheld/0.6.1
Strict-Transport-Security: max-age=63072000
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Vary: Accept-Encoding,Cookie
Age: 7
''')
response=('''
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8




<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>A simple webpage</title>
</head>
<body>
  <h1>Simple HTML5 webpage</h1>
  <p>Hello, world!</p>
</body>
</html>
''')
while True:
    connection, addr = sock.accept()
    print('conn:',connection,'addr',addr,'recv',connection.recv(1600))
    connection.sendall(bytes(response,'utf-8'))
    

# Create a TCP/IP socket Content-Length: 55743
 Connection: keep-alive
 Cache-Control: s-maxage=300, public, max-age=0
 Content-Language: en-US
 Date: Thu, 06 Dec 2018 17:37:18 GMT
 ETag: "2e77ad1dc6ab0b53a2996dfd4653c1c3"
 Server: meinheld/0.6.1
 Strict-Transport-Security: max-age=63072000
 X-Content-Type-Options: nosniff
 X-Frame-Options: DENY
 X-XSS-Protection: 1; mode=block
 Vary: Accept-Encoding,Cookie
 Age: 7 HTTP/1.1 200 OK
 Content-Type: text/html; charset=utf-8
 
 
 
 
 <!DOCTYPE html>
 <html lang="en">
 <head>
   <meta charset="utf-8">
   <title>A simple webpage</title>
 </head>
 <body>
   <h1>Simple HTML5 webpage</h1>
   <p>Hello, world!</p>
 </body>
 </html>