Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在使用python';什么是http服务器?_Python_Content Type_Httpserver - Fatal编程技术网

在使用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