Given a simple program for testing CGI with Apache server
#!C:/Python311/python.exe
html = """<!doctype html />
<html>
<head>
</head>
<body>
<h1>Hello CGI World</h1>
</body>
</html>"""
print( "Content-Type: text/html" )
print( f"Content-Length: {len(html)}" )
print( "" )
print( html )
The problem in len(html)
result less than actual. In editor (fig.1) we see 98 selected symbols.
But in browser we see 91 symbol
And response body cropped by it length
I tried to display string symbol-by-symbol in Python console and found out that '\n' symbols comes alone while in editor and browser they are '\r\n' (my suggestion). In any case single-line string has no problem.
I tried to replace '\n' for '\r\n' (.replace('\n','\r\n')
) but the problem not solves, browser shows extra 'CR' symbools and body still cropped.
Thanks forward for any ideas