1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 12:07:19 +00:00
TiddlyWiki5/server.js

26 lines
685 B
JavaScript
Raw Normal View History

2011-11-22 14:29:29 +00:00
// Cook a TiddlyWiki recipe and serve the result over HTTP
//
// Usage: node server.js <recipefile>
"use strict";
var TiddlyWiki = require("./js/TiddlyWiki.js").TiddlyWiki,
Recipe = require("./js/Recipe.js").Recipe,
2011-11-22 14:29:29 +00:00
http = require("http"),
fs = require("fs"),
url = require("url"),
2011-11-30 19:35:01 +00:00
path = require("path"),
util = require("util");
2011-11-22 14:29:29 +00:00
var filename = process.argv[2];
http.createServer(function(request, response) {
2011-11-22 14:29:29 +00:00
response.writeHead(200, {"Content-Type": "text/html"});
var store = new TiddlyWiki(),
theRecipe = new Recipe(store,filename,function() {
response.end(theRecipe.cook(), "utf-8");
});
2011-11-22 14:29:29 +00:00
}).listen(8000);
2011-11-30 19:35:01 +00:00
util.puts("Server running at http://127.0.0.1:8000/");