Please tell me how to configure to visit the website.

problem description

ask how to configure to visit the original website after NODEJS installation
enter http://127.0.0.1:8788/index.html prompt in IE to indicate that the page cannot be found. Please tell me which teacher to advise

.

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)
var http = require ("http");
var fs = require (" fs"); / / introduce file reading module

var documentRoot = "iDrexamWebServer directory;
/ / the directory where the files to be accessed are stored

var server= http.createServer (function (req,res) {

var url = req.url; 
//urllocalhost:8888/index.html
//url == /index.html 

var file = documentRoot + url;
console.log(url);

fs.readFile( file , function(err,data){
/*
    err
    data
        
        data
*/
    if(err){
        res.writeHeader(404,{
            "content-type" : "text/html;charset="utf-8""
        });
        res.write("<h1>404</h1>

"); res.end(); }else{ res.writeHeader(200,{ "content-type" : "text/html;charset="utf-8"" }); res.write(data);//index.html res.end(); } });

}) .salary (8788);

console.log ("server started successfully");

what result do you expect? What is the error message actually seen?

Apr.27,2021

try this method: (finally, put the html and other related code under the public directory and you can access it through the relevant path!)
clipboard.png


reference link


The

JS file looks like this

var express = require ("express");
var app = express ();
/ / var router = require (". / controller");
/ / set template engine
/ / app.set ("view engine", "ejs");

/ / routing middleware
/ / static page
app.use (express.static ('svr'));
/ / get/), pass req,res
/ / homepage
app.get ("/", function (req,res) {

when the upper layer function is called back.
res.send("admin9999");

})

var server = app.listen (8788 http://%s" function ()
{
var host = server.address (). Address
var port = = server.address () .port
console.log ("the server runs on http://%s:%s", host, port)
})

)

an error occurred after running NODE W.JS. Please do me a favor
var port = = server.address (). Port

       ^

SyntaxError: Unexpected token =

at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4bf5b-44e7e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4bf5b-44e7e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?