정적 파일을 제공하려면 express의 기본 제공 미들웨어인 express.static 을 사용해야한다
app.use(express.static(__dirname + "public"));
위와 같이 설정하면 public 이 포함된 파일을 모두 로드할 수 있다
http://localhost:3000/images/kitten.jpg
http://localhost:3000/css/style.css
http://localhost:3000/js/app.js
http://localhost:3000/images/bg.png
http://localhost:3000/hello.html
express.static 을 여러 번 호출해서 사용할 수 있으며, 특정 경로를 지정해 그 경로를 통해 파일을 로드할 수도 있다
app.use("/static", express.static(__dirname + "public"));
http://localhost:3000/static/images/kitten.jpg
http://localhost:3000/static/css/style.css
http://localhost:3000/static/js/app.js
http://localhost:3000/static/images/bg.png
http://localhost:3000/static/hello.html
※ 모든 경로를 적을 때는 상대경로보단 절대 경로를 쓰는 것을 권장한다