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 = HTTPResponse[
GenerateHTTPResponse ExportString[ToExpression[inputString],@ "SVG"]ExportForm[
, <|"ContentType" ->ToExpression[inputString], "image/svg+xml"|>"SVG"
]
; WriteString[client, ExportString[response, "HTTPResponse"]]
; Close @ client
]
]
]
(* DeleteObject[server]
Close[server["Socket"]]
*)