在使用python';什么是http服务器?
我尝试使用在使用python';什么是http服务器?,python,content-type,httpserver,Python,Content Type,Httpserver,我尝试使用send\u标题('Content-Type','text/html')。但是,这不起作用。可能需要双引号?看见我希望这能有所帮助。以下内容适用于从http.server.BaseHTTPRequestHandler派生的类中的我: self.send_response(200) self.send_header("Content-type", "text/plain") self.end_headers() # Your response body follows with self
send\u标题('Content-Type','text/html')
。但是,这不起作用。可能需要双引号?看见我希望这能有所帮助。以下内容适用于从http.server.BaseHTTPRequestHandler派生的类中的我:
self.send_response(200)
self.send_header("Content-type", "text/plain")
self.end_headers()
# Your response body follows with self.wfile.write()
请参阅更多和。我尝试了双引号,但效果不佳。看起来有效的是“内容类型”而不是“内容类型”(使用下划线而不是连字符)。但是,我需要这是一个连字符,以便其他一些依赖于“Content Type”的程序可以工作。您可能希望查看响应中的实际标头:即使在API调用中将其设置为Content_Type,它也可以在实际标头中正确使用-version