Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이유제
/
CultureGallery
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
송효섭
2020-12-05 03:56:13 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5300e5e5d8940c47e8ceeff4d009b8425e95cd68
5300e5e5
1 parent
c62cf2ef
index.js update for delete main.js
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
52 deletions
app.js
login/login.js
routes/index.js
routes/main.js
app.js
View file @
5300e5e
...
...
@@ -3,7 +3,7 @@ const path = require('path');
const
app
=
express
();
//화면 별 router 연결, 라우터 호출해서 페이지를 불러오는데 사용함.
var
mainRouter
=
require
(
'./routes
/main
'
)
//호출시 main.js 실행 (main.js : title 할당하고 main.html 열어줌)
var
mainRouter
=
require
(
'./routes'
)
//호출시 main.js 실행 (main.js : title 할당하고 main.html 열어줌)
var
loginRouter
=
require
(
'./routes/login'
)
//디폴트 포트 값 : 8000
app
.
set
(
'port'
,
process
.
env
.
PORT
||
8000
);
...
...
@@ -22,34 +22,11 @@ app.use('/login', loginRouter);
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'public'
)));
// app.get('/', (req, res) => {
// //res.send('Server is working');
// // res.sendFile(path.join(__dirname, '/html/main.html'));
// res.sendFile(__dirname + "/html/main.html");
// console.log(app.get('port'), '번 포트 대기 중');
// });
// app.get('/login', (req, res) => {
// console.log('로그인 페이지 오픈 시도됨.');
// res.sendFile(__dirname + "/html/login.html");
// // fs.readFile('./html/login.html', function (err, data) {
// // res.writeHead(200, { 'Content-Type': 'text/html' });
// // res.end(data);
// // })
// })
app
.
get
(
'/logout'
,
function
(
req
,
res
)
{
res
.
send
(
"Logout success"
);
});
app
.
post
(
'/'
,
function
(
req
,
res
)
{
res
.
send
(
"POST request"
);
});
app
.
listen
(
app
.
get
(
'port'
),
()
=>
{
console
.
log
(
`Server is running at
${
app
.
get
(
'port'
)}
`
);
});
var
contentsRouter
=
require
(
'./contents/contents'
);
app
.
use
(
'/contents'
,
contentsRouter
);
...
...
login/login.js
View file @
5300e5e
var
http
=
require
(
'http'
);
var
fs
=
require
(
'fs'
);
var
app
=
http
.
createServer
(
function
(
request
,
response
)
{
var
url
=
request
.
url
;
if
(
url
==
'/'
)
{
var
app
=
http
.
createServer
(
function
(
request
,
response
)
{
var
url
=
request
.
url
;
if
(
url
==
'/'
)
{
url
=
'/send.html'
;
}
if
(
url
==
'/loginmainpage'
)
{
url
=
'/loginmainpage.html'
;
}
}
if
(
url
==
'/loginmainpage'
)
{
url
=
'/loginmainpage.html'
;
}
response
.
writeHead
(
200
);
response
.
end
(
fs
.
readFileSync
(
__dirname
+
url
));
response
.
end
(
fs
.
readFileSync
(
__dirname
+
url
));
});
app
.
listen
(
8080
);
\ No newline at end of file
...
...
routes/index.js
View file @
5300e5e
var
express
=
require
(
'express'
);
var
router
=
express
.
Router
();
/
* GET home page. */
/
/루트 페이지 (메인페이지)에서 실행됨 : title 할당하고 main.html 띄워줌.
router
.
get
(
'/'
,
function
(
req
,
res
,
next
)
{
res
.
render
(
'/public/html/main'
,
{
title
:
'My Gallery'
});
res
.
render
(
'main.html'
,
{
title
:
'Culture Gallery'
});
console
.
log
(
'main 접속 성공'
);
});
/* GET home page. */
router
.
get
(
'/login'
,
function
(
req
,
res
,
next
)
{
res
.
render
(
'index'
,
{
title
:
'Express'
});
})
module
.
exports
=
router
;
res
.
render
(
'login.html'
,
{
title
:
'Login1'
});
console
.
log
(
'로그인 페이지 접속 성공'
);
});
module
.
exports
=
router
;
\ No newline at end of file
...
...
routes/main.js
deleted
100644 → 0
View file @
c62cf2e
var
express
=
require
(
'express'
);
var
router
=
express
.
Router
();
//루트 페이지 (메인페이지)에서 실행됨 : title 할당하고 main.html 띄워줌.
router
.
get
(
'/'
,
function
(
req
,
res
,
next
)
{
res
.
render
(
'main.html'
,
{
title
:
'Culture Gallery'
});
console
.
log
(
'main 접속 성공'
);
});
/* GET home page. */
router
.
get
(
'/login'
,
function
(
req
,
res
,
next
)
{
res
.
render
(
'login.html'
,
{
title
:
'Login1'
});
console
.
log
(
'로그인 페이지 접속 성공'
);
});
module
.
exports
=
router
;
\ No newline at end of file
Please
register
or
login
to post a comment