How can you load the .js .csv and .css files included within an HTML file, displayed with Node.js? (Without frameworks like Express)
E.g. <script src="clock.js"></script>
In Firefox, it shows that the page, fs.readFile('./index.html'), is requesting clock.js, jquery.js, etc. as html files, probably because of response.writeHead being text/html.
Is there a way to do:
if file included in index.html = .js
set writeHead to application/javascript
if file included in index.html = .css
set writeHead to text/css
Without specifying in advance what files index.html may include? (e.g. if in the future, index.html also uses menu.js, you wouldn't need to update the node.js script)
Is there a way to see what files are being requested by index.html, then modify the headers of those files (e.g. .js has application/javascript)?
httpmodule ? This is a kind of routing, you can check the requested URL address and if it ends in.jsset the headers forJavaScript, etc...htmlfile and request the other resources included in that file. You just need to deal with requests coming from the browser. nodejs.org/api/http.html