[英]Multiline String makes python cgi script into download
I am currently learning about cgi-scripts on an Apache webserver.我目前正在学习 Apache 网络服务器上的 cgi 脚本。 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.我遇到了一个奇怪的问题,当我单独打印 html 文件的每一行时,它会工作,但如果我使用多行字符串,它就会被下载。
#!/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.我能够通过在内容类型之前没有新行来修复它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.