简体   繁体   中英

Multiline String makes python cgi script into download

I am currently learning about cgi-scripts on an Apache webserver. I ran into a wierd issue where when I am printing every line of the html-file seperately it wokrs, but if I use a multiline string it gets made into a download.

#!/usr/bin/python3.9

website = f"""
Content-Type: text/html\n\n
<p>hello</p>
"""

print(website)

vs

#!/usr/bin/python3.9

print("Content-Type: text/html\n\n")
print("<p>hello</p>")

I was able to fix it by not having a new line before Content type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM