This is a very simple thing to do naïvely. You make a form POST to a CGI script that invokes LaTeX and then uses something like dvipng to produce a graphic from the result.
If you take the appropriate precautions, it can be safe to do in Linux using TeX Live. (Those precautions include setting openin_any = p, chroot jails, and short timeouts.) When this paper was published, there was not an option similar to openin_any on MiKTeX and that lead to complete system compromise. (I don't know if the situation has changed.) And for the default configuration on TeX Live, it lead to being able to read arbitrary files on the server.
Bottom line: I wouldn't recommend it.