(status_code: int, message: str)
| 41 | |
| 42 | |
| 43 | def format_error(status_code: int, message: str) -> bytes: |
| 44 | reason = http.status_codes.RESPONSES.get(status_code, "Unknown") |
| 45 | return ( |
| 46 | textwrap.dedent( |
| 47 | f""" |
| 48 | <html> |
| 49 | <head> |
| 50 | <title>{status_code} {reason}</title> |
| 51 | </head> |
| 52 | <body> |
| 53 | <h1>{status_code} {reason}</h1> |
| 54 | <p>{html.escape(message)}</p> |
| 55 | </body> |
| 56 | </html> |
| 57 | """ |
| 58 | ) |
| 59 | .strip() |
| 60 | .encode("utf8", "replace") |
| 61 | ) |
no test coverage detected
searching dependent graphs…