Question

I'm trying to use the built-in SimpleHTTPServer in Python to serve a static page locally. I start it with python -m SimpleHTTPServer.

At the moment, the HTML is just

<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        Hi
    </body>
</html>

The server returns the page with status 200 but the browser console says ERR_CONTENT_LENGTH_MISMATCH and won't render anything. If I change the content to single line of text it shows up fine. Adding another line breaks it again. Per the comments, it seems like the problem is with newlines. I'm writing this in Sublime Text (on Windows) and using Chrome to view, if that helps.

Was it helpful?

Solution

It turned out to be a Sublime Text issue. Just had to change the line endings in View > Line Endings to Unix.

Big ups to this post:

Fixing Sublime Text 2 line endings?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top