Serve Static Files from Node.js with POST data

994 views Asked by At

I run a node.js server, and use node-static to serve static HTML files.

var nodeStatic = require('node-static');
var file = new nodeStatic.Server('./public');
..
file.serveFile('/file.html', 500, {}, request, response); 

What i would like to do is, serve a static HTML file with a set of variables attached (e.g. over the POST method). I want to include dynamic information in the HTML file, and would like to be able to hand over that dynamic data - ideally in JSON format - from the node server.

Can node-static do that? Or is there another module out there that can?

1

There are 1 answers

0
Mustafa On

What you want is templating. It can be done in both client-side and server-side. (Jade is my favorite) But the client-side performance can be unsatisfying sometimes. Here have a look at these Client-Side Template Engine Benchmarks.