Very often SVG makes sense, it will scale well with magnification. This idea does not deserve a separate answer so additionally I rewrote the code in a more idiomatic style:
server = SocketListen[8000
, Function[{assoc}
, Module[
{ client = assoc["SourceSocket"], inputString, response}
, inputString = ImportString[assoc["Data"], "HTTPRequest"] @ "Query" // Lookup["expr"]
; response = GenerateHTTPResponse @ ExportForm[
ToExpression[inputString], "SVG"
]
; WriteString[client, ExportString[response, "HTTPResponse"]]
; Close @ client
]
]
]
(* DeleteObject[server]
Close[server["Socket"]]
*)