0

Just starting to pick up node js, and I have a very basic question. Can someone please tell me what does /.*/ in the following line of code mean?

app.get(/.*/, express.static(__dirname + '/public'))

If I have 2 html files in the public directory, how should this code be if, say i want to serve myHome.html?

Thanks for help!

mint
  • 21
  • 2
  • Hey... I think you should read more about serving express static files at http://expressjs.com/en/starter/static-files.html#serving-static-files-in-express – filipe Jun 02 '19 at 12:20
  • /.*/ is the url path. The wildcard means anything, so it will match site.com/.dog/ and site.com/.cat/ – filipe Jun 02 '19 at 12:27
  • About how to serve a single file: https://stackoverflow.com/questions/11473607/node-js-express-js-what-is-the-easiest-way-to-serve-a-single-static-file – filipe Jun 02 '19 at 12:28
  • That’s actually two questions. The first parameter of get it’s regular expression that means “matches any character (except for line terminators)”. – Dayron Gallardo Jun 02 '19 at 13:40

1 Answers1

0

To serve static in express

app.use(express.static(__dirname + '/public'))
Vengleab SO
  • 716
  • 4
  • 11