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:29:53 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
66b9289ee25af4910e4f0049b0fff0abd2775c70
66b9289e
2 parents
639438b3
22a80e5c
Merge branch 'integrated
#1
_ksy' into 'integrated
#1
'
Integrated
#1
ksy See merge request
!1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
22 deletions
app.js
views/main.pug
app.js
View file @
66b9289
...
...
@@ -9,37 +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
+
'?
returnType=XML&
serviceKey='
+
$key
+
'&page='
+
$page
+
'&perPage='
+
$perPage
;
const
$api_url
=
$base_url
+
'?serviceKey='
+
$key
+
'&page='
+
$page
+
'&perPage='
+
$perPage
;
console
.
log
(
$api_url
);
//해당 URL로 요청
app
.
post
(
'/'
,
function
(
req
,
res
,
next
){
const
searchWord
=
req
.
body
.
region
;
//지역 키워드
app
.
listen
(
3000
,
function
(){
console
.
log
(
'Connected 3000 port!'
);
});
request
(
$api_url
,
function
(
err
,
response
,
body
){
if
(
err
)
throw
err
;
request
(
$api_url
,
function
(
err
,
res
,
body
){
$
=
cheerio
.
load
(
body
);
const
$infoList
=
$
(
'item'
)
console
.
log
(
$infoList
.
html
());
console
.
log
(
$infoList
.
length
);
// let name = $infoList.find('orgnm').text();
// let location = $infoList.find('orgZipaddr').text();
// console.log(`기관명: ${name}, 위치: ${location}`);
})
//data부분만 추출
var
obj
=
JSON
.
parse
(
body
).
data
;
// console.log(obj);
//검색한 지역 포함한 모든 data 담기
let
searchList
=
obj
.
filter
(
searchList
=>
{
return
searchList
.
orgZipaddr
.
includes
(
searchWord
);
});
// console.log(searchList);
//result라는 변수에 담아 결과 보내기
res
.
render
(
'main'
,
{
result
:
searchList
});
})
app
.
post
(
'/search'
,
function
(
req
,
res
){
res
.
send
(
'내가 검색한 지역은 '
+
req
.
body
.
region
);
})
app
.
get
(
'/'
,
function
(
req
,
res
){
app
.
listen
(
3000
,
function
(){
console
.
log
(
'Connected 3000 port!'
);
});
app
.
get
(
'/'
,
function
(
req
,
res
){
res
.
render
(
'main'
);
})
\ No newline at end of file
...
...
views/main.pug
View file @
66b9289
...
...
@@ -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