diff options
author | ache <ache@ache.one> | 2019-01-30 23:51:57 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2019-01-30 23:51:57 +0100 |
commit | d5608829b28e8e833435fe4ec93565a93a89d764 (patch) | |
tree | 763395f4777390f98d72934a5c127b71f54c7520 /src/app.mjs | |
parent | New base (diff) |
New code
Diffstat (limited to 'src/app.mjs')
-rw-r--r-- | src/app.mjs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/app.mjs b/src/app.mjs index 2903c58..94e0604 100644 --- a/src/app.mjs +++ b/src/app.mjs @@ -1,5 +1,6 @@ 'use-strict'; +const fs = require('fs'); const express = require('express'); const mustache = require('mustache-express'); const path = require('path'); @@ -10,11 +11,18 @@ app.engine('html', mustache()); app.set('view engine', 'html'); app.set('views',path.join(__dirname, 'views')); -app.use(express.static('default')); +app.use('/default', express.static('default')); app.use(express.static('static')); app.get('/', (req, res) => { - res.render('index.html', {yourdata: 'Hello from Mustache Template'}); + + const listFile = fs.readdirSync("./default"); + const options = listFile.map( file => { + const text = file.replace('.json', ''); + return `<option value="${file}">${text}</option>`; + }); + console.log(options); + res.render('index', {listFile: options.join('')}); }); const server = app.listen(8100, () => { |