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-05-28 03:28:15 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9346e795b96e5e61f9188f29be6e7081acbb74cd
9346e795
1 parent
9c3c7a79
HTML 페이지와 Nodejs 연결 (세부 내용 미구현)
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
4 deletions
Index.html
base.js
timetable.html
Index.html
View file @
9346e79
...
...
@@ -19,10 +19,10 @@
<h2>
버스별 시간표 조회
</h2>
<p>
m월 d일 오늘 운행하는 버스들
</p>
<ul>
<li><a
href=
"
timetable.html
"
>
5100
</a></li>
<li><a
href=
"
timetable.html
"
>
M5107
</a></li>
<li><a
href=
"
timetable.html
"
>
9
</a></li>
<li><a
href=
"
timetable.html
"
>
7000
</a></li>
<li><a
href=
"
http://localhost:23023/?busNum=5100
"
>
5100
</a></li>
<li><a
href=
"
http://localhost:23023/?busNum=M5107
"
>
M5107
</a></li>
<li><a
href=
"
http://localhost:23023/?busNum=9
"
>
9
</a></li>
<li><a
href=
"
http://localhost:23023/?busNum=7000
"
>
7000
</a></li>
<li>
etc
</li>
</ul>
<br>
...
...
base.js
View file @
9346e79
var
http
=
require
(
'http'
);
var
fs
=
require
(
'fs'
);
var
url
=
require
(
'url'
);
var
app
=
http
.
createServer
(
function
(
request
,
response
){
var
_url
=
request
.
url
;
var
queryData
=
url
.
parse
(
_url
,
true
).
query
;
if
(
_url
==
'/'
){
_url
=
'/Index.html'
;
}
if
(
_url
==
'/favicon.ico'
){
return
response
.
writeHead
(
404
);
}
response
.
writeHead
(
200
);
console
.
log
(
queryData
.
busNum
);
if
(
queryData
.
busNum
!=
null
){
// 버스번호를 요청했을때 타임테이블 페이지로 전환
var
timetableHTML
=
`
<!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="Index.html"><p style="text-align:center;">BTT</p></a></h1>
<br>
<h2>
${
queryData
.
busNum
}
BUS Time Table</h2>
<p> Response from API server ... </p>
</body>
</html>
`
;
response
.
end
(
timetableHTML
);
}
else
{
// 아니라면, url 따라감
response
.
end
(
fs
.
readFileSync
(
__dirname
+
_url
));
}
});
app
.
listen
(
23023
);
\ No newline at end of file
...
...
timetable.html
View file @
9346e79
<!-- 이 문서는 base.js에 timetableHTML로 저장되어 있음. 따라서 이 문서는 직접적으로 사용하지 않음-->
<!doctype html>
<html>
<head>
...
...
Please
register
or
login
to post a comment