vendredi 28 décembre 2018

Node.js serve html files

so i have a directory structure like this :

    server
       code
         app.js
         web
           html
               index.html
           css
               index.css
           scripts
               index.js

my app.js code is trying to serve the html file index.html but shows errors this is the code :

    app.get('/web',function(req,res) 
    {
        res.sendFile('../web/html/index.html');
    })

what path to pass to sendFile() and make it work appropriately so that the script file and css are also found by the html file when it runs ?

PS : if question is duplicate please post the answer here too . Im new to node.js so any help would be appreciated . Thanks in advance .




Aucun commentaire:

Enregistrer un commentaire