김서연

Merge branch 'integrated#1_ksy' into 'integrated#1'

Integrated#1 ksy



See merge request !1
......@@ -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=10;
const $perPage=30000;
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
......
......@@ -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
......