title: Python server showing html as text rather than rendering it
body: <p>I'm trying to make a server the long way for more control/ learning. when i try to make a simple one with bash i get mimetype errors.</p>
  <p>I must be looking at this the wrong way but my server seems to make the browser render the html as text. the html i get in the browser is weird too.</p>
  <p>any help would be mush appreciated!</p>
  <p><strong>server.py</strong></p>
  <pre><code>from http.server import HTTPServer,BaseHTTPRequestHandler
  
  HOST = &quot;localhost&quot;
  PORT = 7800
  
  class FeedSpeedServer(BaseHTTPRequestHandler):
  
      def do_GET(self):
  
  
          if self.path == &quot;/&quot;:
              self.path = 'index.html'
          
          try:
              
              self.send_header(&quot;content-type&quot;, &quot;text/html&quot;)
              self.send_header(&quot;content-type&quot;, &quot;text/javascript&quot;)
              self.send_header(&quot;content-type&quot;, &quot;text/css&quot;)
              self.end_headers()
              self.file = open(self.path).read()
              self.wfile.write(self.file.encode())
              self.send_response(200)
              
          except:
              self.file = &quot;file not found&quot;
              self.send_response(404)
  
  
  httpd = HTTPServer((HOST, PORT), FeedSpeedServer)
  print(&quot;server running...&quot;)
  httpd.serve_forever()
  print(&quot;server Stopped&quot;)
  </code></pre>
  <p>My web browser shows this...</p>
  <p><a href="https://i.stack.imgur.com/fPwbP.png" rel="nofollow noreferrer">screenshot</a></p>