Between the intermediate server node using the express plug-in hosting static files

const Express = The require ( ' Express ' );
 const App = Express (); 

// implement static resource services 
the let = app.use Server (Express. static ( ' public ' )); 

server.listen ( 3000 , () => { 
    the console.log ( ' public folders to the server has been hosting ' ) 
})

 

Create a public folder in the catalog, add a virtual directory

// between the intermediate node server hosting static files using the express plug- 

const express = The require ( ' express ' );
 const App = express (); 

// implement static resource service / abc can add a virtual directory to access the directory plus abc 
the let App Server = .use ( ' ABC ' , Express. static ( ' public ' )); 

server.listen ( 3000 , () => { 
    the console.log ( ' public folders to the server has been hosting ' ) 
})

 

Guess you like

Origin www.cnblogs.com/hack-ing/p/12111599.html