Whenever I attempt to set up a NodeJs server and run it with an HTML file, the images are not loading properly.
Here is the NodeJS code snippet:
var http = require('http');
var fs = require('fs');
fs.readFile('main.html', function (err, html) {
if (err) {
throw err;
}
http.createServer(function(request, response) {
response.writeHeader(200, {"Content-Type": "text/html"});
response.write(html);
}).listen(8000);
});
The body content in the HTML file looks like this:
<body>
<img id ="gug" src="./gugle.png">
<form>
<div id = "inp">
<input type="text" id = "tb" placeholder="Search Results" value="">
</div>
<span style=" margin-left: 420px"> <input type="submit" style = "height: 30px;width: 120px; font-family: Arial; font-weight: bold" onclick="alert_prompt('tb')" value="Google Search">
<input type="button" style = "height: 30px;width: 120px; font-family: Arial; font-weight:bold" onclick= "lolfnc()" value = "I'm feeling lucky">
</span>
</form>
<p style="margin-left: 370px; font-family: 'Times New Roman'">
Google.co.in offered in:<span style="color: blue; font-size: small; font-family: SansSerif"> हिन्दी বাংলা తెలుగు मराठी தமிழ் ગુજરાતી ಕನ್ನಡ മലയാളം ਪੰਜਾਬੀ</span>
</p>
</body>
Both the JavaScript and HTML files are located in the same directory. Any assistance on resolving this issue would be greatly appreciated.