first route
This commit is contained in:
@@ -4,10 +4,17 @@ var app = express();
|
||||
|
||||
app.use(express.static(__dirname + '/resources/public'));
|
||||
|
||||
app.get('/api', function (req, res) {
|
||||
res.send(page.build("api"));
|
||||
app.get('/:year/:month/:day/:title', function (req, res) {
|
||||
var params = req.params;
|
||||
var id = params.year + "/" + params.month + "/" + params.day + "/" + params.title;
|
||||
res.send("opening note " + id);
|
||||
});
|
||||
|
||||
app.get('/:link', function (req, res) {
|
||||
|
||||
});
|
||||
|
||||
|
||||
var server = app.listen(3000, function () {
|
||||
console.log('NoteHub server listening on port %s', server.address().port);
|
||||
});
|
||||
+1
-2
@@ -7,11 +7,10 @@ var template = fs.readFileSync("resources/template.html", "utf-8");
|
||||
var buildHTML = (title, content) => template
|
||||
.replace("%TITLE%", title)
|
||||
.replace("%CONTENT%", content);
|
||||
var apiPage = buildHTML("API", marked(fs.readFileSync("API.md", "utf-8")));
|
||||
|
||||
module.exports.build = id => {
|
||||
if (CACHE.has(id)) return CACHE.get(id);
|
||||
var content = id == "api" ? apiPage : "This is page " + id;
|
||||
var content = "This is page " + id;
|
||||
CACHE.set(id, content);
|
||||
return content;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user