Commit 1f458365 authored by eric's avatar eric

This node.js app lets you select from the command line which content file to use

works by overriding setup.js
parent 93437b8a
*.autosave
*.swp
node_modules
var fs = require('fs');
var path = require('path');
var cheerio = require('cheerio');
var express = require('express');
var app = express();
if (process.argv.length < 3) {
console.log("Please specify an HTML file as a command line parameter");
process.exit(1);
}
var htmlPath = path.resolve(process.argv[2]);
var htmlFolder = path.dirname(htmlPath);
app.get('/', function (req, res, next) {
fs.readFile("index.html", function (err, data) {
if (err) throw err;
res.set('Content-Type', 'text/html');
res.send(data);
});
});
app.get('/setup/setup.js', function (req, res, next) {
res.set('Content-Type', 'application/javascript');
res.send('var nb_page = 24; var content = "' + process.argv[2] + '";');
} );
app.use(express.static(htmlFolder));
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
{
"name": "editor",
"version": "0.0.1",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "~4.10.2",
"cheerio": "~0.18.0",
"body-parser": "~1.9.2"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment