(html)
| 47 | |
| 48 | |
| 49 | def _html_resource(html): |
| 50 | |
| 51 | class HtmlResource(Resource): |
| 52 | isLeaf = True |
| 53 | template = html |
| 54 | |
| 55 | def __init__(self, http_port=None, https_port=None): |
| 56 | Resource.__init__(self) |
| 57 | self.http_port = http_port |
| 58 | self.https_port = https_port |
| 59 | |
| 60 | @use_chunked_encoding |
| 61 | def render(self, request): |
| 62 | response = self.template % dict( |
| 63 | http_port=self.http_port, |
| 64 | https_port=self.https_port |
| 65 | ) |
| 66 | # Twisted wants response to be bytes |
| 67 | return response.encode('utf-8') |
| 68 | |
| 69 | return HtmlResource |
| 70 | |
| 71 | |
| 72 | JsRender = _html_resource(""" |
no outgoing calls
no test coverage detected