I'm trying to serve up some static files using an extremely basic node.js server. The aim is to serve a html file with a script tag referencing a javascript file. When opening the application in the browser the html renders fine, the problem is with the js file. In the browser the js file has the html code in it and not the js code.
SERVERC CODE:
var http = require('http')
var fs = require('fs')
var port = 3000;
var app = http.createServer(function(req, res){
var html = fs.createReadStream('./index.html')
html.pipe(res);
})
app.listen(port, function(){
console.log('Listening on port ' + port)
})
HTML CODE(index.html):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello</title>
</head>
<body>
<h1>Hello</h1>
<script src="./some.js"></script>
</body>
</html>
JAVASCRIPT CODE(some.js):
console.log("Hello")
DIRECTORY STRUCTURE:
|-index.html
|-some.js
|-app.js(server)