Twisted html 文件列表给出 "Request did not return bytes" 错误

Twisted html File listing gives "Request did not return bytes" error

我有一个 Twisted 网络应用程序。我想为 GET 请求调用 Html 文件。(我的 Html 文件与我的 Twisted 应用 运行s 位于同一文件夹中)

    class Root(resource.Resource):
        isLeaf = False


        def render_GET(self, request):
            return self.returnResponse(request)

        def returnResponse(self, request):
            request.setHeader(b"content-type", b"text/html")
            return File("Info.html")

site = Root()
site.putChild('cache', NetworkCacheManager())
endpoints.serverFromString(reactor, "tcp:port=8080:interface=0.0.0.0").listen(server.Site(site))
reactor.run()

当我 运行 服务器时,我收到 500 错误;

Request did not return bytes

Request:

<Request at 0x10b042b48 method=GET uri=/ clientproto=HTTP/1.1>

Resource:
<__main__.Root instance at 0x10b0302d8>

Value:
FilePath('/Users/ratha/projects/TestPython/com/lob/Info.html')

这里有什么问题?

我修好了;

def returnResponse(self, request):
    f = open('Info.html', 'r')
    request.setHeader(b"content-type", b"text/html")
    return f.read()