CGI Articles

Page 2 of 2

What Content-type is required to write Python CGI program?

Rajendra Dharmkar
Rajendra Dharmkar
Updated on 24-Mar-2026 409 Views

When writing Python CGI programs, you must specify a Content-type header to tell the browser how to interpret the response. This is essential for proper web communication between your CGI script and the client's browser. Basic Content-type Header The first line of any CGI program output must be a Content-type header followed by a blank line ‒ #!/usr/bin/env python3 print("Content-type: text/html\r\r") print("") print("Hello CGI") print("") print("Hello from Python CGI!") print("") print("") Why the Content-type Header is Required The Content-type header tells the browser: What type of content to expect (HTML, ...

Read More
Showing 11–11 of 11 articles
« Prev 1 2 Next »
Advertisements