I learned some codes to make a mini HTTP server in MMA way here.
server=SocketListen[8000,Function[{assoc},Block[{client=assoc["SourceSocket"]},
Block[{html,expr},
expr=First@StringCases[assoc["Data"],RegularExpression["GET /\\?expr=([^ ]+)"]->"$1"];
html=ToString@InputForm@ToExpression@URLDecode@expr;
WriteString[client,"HTTP/1.1 200 OK\r\nDate: "<>DateString[]<>"\r\nContent-Type: text/html\r\nContent-Length: "<>
ToString@StringLength@html<>"\n\n"<>html];
Close[client]]]]]
do not forget to close it when finished.
DeleteObject[server]
Close[server["Socket"]]
by the upper codes, we could pass exprs to MMA and get results in TEXTs way,
I want to know how to show the Plots or Graphics with these codes in web browsers like Chrome?
I wonder that, MMA could be used as web server, there should be some frameworks to help this becoming true, like Express upon node.js. is this worth to do sth?




ExportString[expr,"PNG"]and changing the response content-type toimage/pngmight work. – Carl Lange Jan 18 '19 at 18:18HTMLFragmentcan help on bothTEXTorPLOTs if setContent-Typevaluetext/html– Jerry Jan 19 '19 at 02:44Exit[]executed whenWloframAlphafirstly lanched as public knowledge engine. – Jerry Jan 19 '19 at 02:48