# Python-Quellcode

### Wir geben hier nur die entscheidenden Passage an:

request = ''
block_size = 512
while True:

> data = connection.recv(block_size)

> request = request + str(data, 'UTF-8')

> if result.find('\r\n\r\n') >= 0:

> > break

get = request.partition('GET /')[2]
filename = get.partition(' ')[0]
extension = filename.partition('.')[2]
print(request)
print('Requested File: ', filename, ', Extension: ', extension)
connection.send(http_header(extension))
if extension == 'htm' or extension == 'jpg':

> f = open(filename, 'rb') # Txt-Datei oder Bild-Datei oder...

> block_size = 512

> while True:

> > data = f.read(block_size)

> > connection.send(data)

> > if len(data) < block_size:

> > > break

> > f.close()

### home