gpt4 book ai didi

python - 让 Apache cgi 在 Python 中发送 json

转载 作者:太空宇宙 更新时间:2023-11-04 09:17:12 25 4
gpt4 key购买 nike

我有一个用于 cgi 的 apache 服务器。我正在用 Python 编写我的 cgis。

只要我的回复是“Content-Type: text/html\n #”的形式,它就有效。

但是如果我发送任何其他内容,我会收到 500 错误并且我的日志显示“脚本中的格式错误的 header 。错误的 header ”我可以更改我的配置以使其正常工作吗?还有什么我可以做的吗?

最佳答案

与所有 CGI 一样,您需要在 header 和正文之间留一个空行。

print 'Content-Type: text/plain'
print
print 'Hello, World!'

关于python - 让 Apache cgi 在 Python 中发送 json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7683597/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com