Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김서연
/
Corona_Vaccination_Medical_Institution
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
3
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김서연
2021-05-19 02:28:18 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
22a80e5cccdbb854b0e63608d21c287102a1be0b
22a80e5c
1 parent
f5e21bd9
의료기관 조회시 목록 출력 성공
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
19 deletions
app.js
views/main.pug
app.js
View file @
22a80e5
...
...
@@ -9,42 +9,46 @@ app.set('views','./views')
app
.
set
(
'view engine'
,
'pug'
);
app
.
use
(
express
.
static
(
'public'
));
//?page=페이지번호&?perPage=페이지당 데이터수
const
$base_url
=
`https://api.odcloud.kr/api/apnmOrg/v1/list`
;
const
$key
=
'4US0H%2BXj%2BmS8IR4YL0%2BUb9H4CcbTr92QxhYULfOEz1DT%2BZaaos4sRfNh6cmAD2Icli862Ysc31%2BaE4pWywDBIA%3D%3D'
;
//임시 매개변수
const
$page
=
1
;
const
$perPage
=
1
0
;
const
$perPage
=
3000
0
;
const
$api_url
=
$base_url
+
'?serviceKey='
+
$key
+
'&page='
+
$page
+
'&perPage='
+
$perPage
;
console
.
log
(
$api_url
);
//해당 URL로 요청
request
(
$api_url
,
function
(
err
,
res
,
body
){
app
.
post
(
'/'
,
function
(
req
,
res
,
next
){
const
searchWord
=
req
.
body
.
region
;
//지역 키워드
request
(
$api_url
,
function
(
err
,
response
,
body
){
if
(
err
)
throw
err
;
var
obj
=
JSON
.
parse
(
body
);
//data부분만 추출
var
obj
=
JSON
.
parse
(
body
).
data
;
// console.log(obj);
for
(
var
i
=
0
;
i
<
obj
.
data
.
length
;
i
++
){
let
name
=
obj
.
data
[
i
].
orgnm
;
let
location
=
obj
.
data
[
i
].
orgZipaddr
;
console
.
log
(
`기관명:
${
name
}
, 위치:
${
location
}
\n`
);
}
// res.render('main', {title: 'misae', data:data, pm10:pm10})
//검색한 지역 포함한 모든 data 담기
let
searchList
=
obj
.
filter
(
searchList
=>
{
return
searchList
.
orgZipaddr
.
includes
(
searchWord
);
});
// console.log(searchList);
//result라는 변수에 담아 결과 보내기
res
.
render
(
'main'
,
{
result
:
searchList
});
})
})
app
.
listen
(
3000
,
function
(){
console
.
log
(
'Connected 3000 port!'
);
});
app
.
post
(
'/search'
,
function
(
req
,
res
){
res
.
send
(
'내가 검색한 지역은 '
+
req
.
body
.
region
);
})
app
.
get
(
'/'
,
function
(
req
,
res
){
res
.
render
(
'main'
);
})
\ No newline at end of file
...
...
views/main.pug
View file @
22a80e5
...
...
@@ -2,8 +2,37 @@ html
head
meta(charset='utf-8')
body
form(action='/search' method="post")
p
input(type='text' name='region' placeholder='지역'
)
h1 COVID-19 의료기관 검색하기
form(action='/' method="post"
)
p
input(type='text' name='region' placeholder='서울시')
input(type='submit')
//result값 있을때만
if result!=NULL
table
tr
th 기관명
th 기관 전화번호
th 기관 주소
th 휴무일 여부
th 점심 시작시간
th 점심 종료시간
th 진료 시작기간
th 진료 종료시간
-for(i=1; i<result.length; i++)
tr
td= result[i].orgnm
td= result[i].orgTlno
td= result[i].orgZipaddr
td= result[i].hldyYn
td= result[i].lunchSttTm
td= result[i].lunchEndTm
td= result[i].sttTm
td= result[i].endTm
\ No newline at end of file
...
...
Please
register
or
login
to post a comment