Get / returns list of available templates
This commit is contained in:
parent
d7f6d4089f
commit
b0c22efc23
1 changed files with 17 additions and 0 deletions
17
index.js
17
index.js
|
@ -173,6 +173,23 @@ app.get('/debug/frame/', async (req, res) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get('/', async (req, res) => {
|
||||||
|
try {
|
||||||
|
var templateList = [];
|
||||||
|
for (var key in templates) {
|
||||||
|
if(templates.hasOwnProperty(key)) { //to be safe
|
||||||
|
templateList.push(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(templateList);
|
||||||
|
res.setHeader('Content-Type', 'application/json')
|
||||||
|
return res.end(JSON.stringify(templateList));
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
return res.status(400).end(err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
app.get('/:templateName/', async (req, res) => {
|
app.get('/:templateName/', async (req, res) => {
|
||||||
if (!templates[req.params.templateName]) return res.status(404).end();
|
if (!templates[req.params.templateName]) return res.status(404).end();
|
||||||
try {
|
try {
|
||||||
|
|
Reference in a new issue