how to send HTML file back to client - hogehoge666/syno_moments_slider GitHub Wiki

1. send HTML texts

res.set('Content-Type', 'text/html');
result.send('<h2>Hello World</h2>');

2. send HTML file

  • If index.html relies on external scripts, the scripts won't be sent with the index.html.
result.sendfile(__dirname + '/index.html');

3. send rendered HTML file

  • Note you need to set up a template engine and prepare a template file
res.render('index', {title: 'Hello World!'});
⚠️ **GitHub.com Fallback** ⚠️