title: Python web server - IndexError when splitting filename
body: <p>I have successfully been able to access my web-server from a browser, downloaded a file on the server and properly viewed it with chrome. However, when the server standbys for approx. 20 seconds, it'll crash with an IndexError.</p>
  
  <pre><code>from socket import *
  serverport = 972
  serverSocket = socket(AF_INET, SOCK_STREAM)
  serverSocket.bind(('', serverport))
  serverSocket.listen(1)
  print 'Standing by...'
  
  while True:
      #Establish the connection
      connectionSocket, addr = serverSocket.accept()
  
      try:
          message = connectionSocket.recv(1024)
          filename = message.split()[1]
          f = open(filename[1:])
          outputdata = f.read()
  
          for i in range(0, len(outputdata)):
              connectionSocket.send(outputdata[i])
          print 'Success! File sent!'
          connectionSocket.close()
  
      except IOError:
          errormessage = 'Error 404 - File not found'
          connectionSocket.send(errormessage)
  </code></pre>
  
  <p>The output i get is the following:</p>
  
  <pre><code>Standing by..
  Success! File sent! #sent everytime i request the webpage on the client localhost:80/helloworld.html
  Traceback (most recent call last):
    File "C:/Users/Nikolai/Dropbox/NTNU/KTN/WebServer/TCPServer.py", line 14, in &lt;module&gt;
      filename = message.split()[1]
  IndexError: list index out of range
  </code></pre>