Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍용민
/
BusTime
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
이의준
2021-06-07 15:58:28 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
735e04dccc03fab254f31237705215ff229564e9
735e04dc
1 parent
d583cfb8
router & server file 브랜치 이동 (View -> control)
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
76 deletions
router/main.js
server.js
router/main.js
deleted
100644 → 0
View file @
d583cfb
var
url
=
require
(
'url'
);
var
request
=
require
(
'request'
);
var
qs
=
require
(
'querystring'
);
const
{
METHODS
}
=
require
(
'http'
);
module
.
exports
=
function
(
app
)
{
app
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
render
(
'Index.html'
);
});
app
.
get
(
'/timetable'
,
function
(
req
,
res
){
// bus list의 특정 버스를 클릭하면, server에 요청
var
_url
=
req
.
url
;
var
queryData
=
url
.
parse
(
_url
,
true
).
query
;
var
busNum
=
queryData
.
busNum
;
const
options
=
{
url
:
'http://IPv4:port/__dirname'
,
method
:
'GET'
,
headers
:
{
}
};
request
.
post
(
{
url
:
'http://34.206.171.225:23023/reqBusInfo'
,
body
:
{
'busNum'
:
busNum
,
'testVariable'
:
'test'
},
json
:
true
}
);
var
resFromServer
=
JSON
.
parse
(
res
);
var
templateTimeTable
=
`
<!doctype html>
<html>
<head>
<title>Time Table</title>
<meta charset="utf-8">
<style type="text/css">
a { text-decoration:none }
</style>
</head>
<body>
<h1><a href="/"><p style="text-align:center;">BTT</p></a></h1>
<br>
<h2>
${
busNum
}
BUS Time Table</h2>
<br>
${
resFromServer
}
</body>
</html>
`
;
res
.
send
(
templateTimeTable
);
});
}
server.js
deleted
100644 → 0
View file @
d583cfb
var
express
=
require
(
'express'
);
var
app
=
express
();
var
router
=
require
(
'./router/main'
)(
app
);
// router모듈인 main.js를 불러와서 app에 전달
//__dirname : 현재 실행중인 폴더 경로
app
.
set
(
'views'
,
__dirname
+
'/views'
);
//서버가 읽을 수 있도록 HTML 의 위치를 정의
app
.
set
(
'view engine'
,
'ejs'
);
//서버가 HTML 렌더링을 할 때, EJS 엔진을 사용하도록 설정
app
.
engine
(
'html'
,
require
(
'ejs'
).
renderFile
);
//서버가 HTML 렌더링을 할 때, EJS 엔진을 사용하도록 설정
var
server
=
app
.
listen
(
23023
,
function
()
{
var
host
=
server
.
address
().
address
var
port
=
server
.
address
().
port
console
.
log
(
"app listening at http://%s:%s"
,
host
,
port
)
})
app
.
use
(
express
.
static
(
__dirname
+
'/public'
));
Please
register
or
login
to post a comment