// NOTE: This is just a demo -- in a production environment, // be sure to spend a few more thoughts on sanitizing user input. // (also, you probably wouldn't use a get request) var http = require("http"), url = require("url"), querystring = require("querystring"), Converter = require("../../Markdown.Converter").Converter, getSanitizingConverter = require("../../Markdown.Sanitizer").getSanitizingConverter, conv = new Converter(), saneConv = getSanitizingConverter(); http.createServer(function (req, res) { var route = url.parse(req.url); if (route.pathname !== "/") { res.writeHead(404); res.end("Page not found"); return; } var query = querystring.parse(route.query); res.writeHead(200, { "Content-type": "text/html" }); res.write(""); var markdown = query.md || "## Hello!\n\nI'm walking\n\nVisit [Stack Overflow](http://stackoverflow.com)\n\nThis is never closed!"; res.write("

Your output, sanitized:

\n" + saneConv.makeHtml(markdown)) res.write("

Your output, unsanitized:

\n" + conv.makeHtml(markdown)) res.write( "

Enter Markdown

\n" + "
" + "
" + "" + "
" ); res.end(""); }).listen(8000);