Page 213 - Nodejs 교과서 개정2판
P. 213

§ Ӓܿ     MPDBMIPTU      ੽ࣘ ചݶ



         ױࣽೠ ޙ੗ৌ ؀न )5.-۽ ਽׹ೞҊ र׮ݶ res.sendFile ݫࢲ٘ܳ ࢎਊೞݶ ؾפ׮  ױ  ౵ੌ੄ ҃۽ܳ QBU
         I ݽٕਸ ࢎਊ೧ࢲ ૑੿೧ঠ ೤פ׮

          index.html

           <html>
           <head>
           		<meta	charset="UTF-8"	/>
           		<title>익스프레스	서버</title>
           </head>
           <body>
           		<h1>익스프레스</h1>
           		<p>배워봅시다.</p>
           </body>
           </html>




          app.js
           const	express	=	require('express');
           const	path	=	require('path');


           const	app	=	express();
           app.set('port',	process.env.PORT	||	3000);


           app.get('/',	(req,	res)	=>	{
           		//	res.send('Hello,	Express');
           		res.sendFile(path.join(__dirname,	'/index.html'));
           });


           app.listen(app.get('port'),	()	=>	{
           		console.log(app.get('port'),	'번	포트에서	대기	중');
           });
   208   209   210   211   212   213   214   215   216   217   218