๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Today I Learned(TIL)/์ŠคํŒŒ๋ฅดํƒ€ ๋‚ด์ผ๋ฐฐ์›€์บ ํ”„

๋ฏธ๋‹ˆ ํ”„๋กœ์ ํŠธ_Day 4

by carrot0911 2024. 11. 8.

ํ•˜๋ฃจ ์š”์•ฝ

์˜ค๋Š˜์€ ๋ณธ์บ ํ”„ 4์ผ์ฐจ!! ๋‚ด์ผ์ด๋ฉด ๋“œ๋””์–ด ๋ฏธ๋‹ˆ ํ”„๋กœ์ ํŠธ์˜ ์ตœ์ข… ๋ฐœํ‘œ๋‹ค..
ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋Š” ๋™์•ˆ Github, HTML, CSS, Javascript.... ๊ทธ๋ฆฌ๊ณ  ํ˜‘์—…์„ ์ œ๋Œ€๋กœ ๊ฒฝํ—˜ํ•  ์ˆ˜ ์žˆ์—ˆ๋˜ ๊ฒƒ ๊ฐ™๋‹ค!

์šฐ๋ฆฌ๊ฐ€ ๊ณ„ํšํ–ˆ๋˜ ๊ฒƒ๋ณด๋‹ค ๋” ๋ฉ‹์ง„ ๊ฒฐ๊ณผ๋ฌผ๋กœ ๋‚˜์˜จ ๊ฒƒ ๊ฐ™์•„์„œ ๋ฟŒ๋“ฏํ–ˆ๋‹ค.

์˜ค๋Š˜์€ ๋‘ ๊ฐ€์ง€ ์—๋Ÿฌ๋ฅผ ํ•ด๊ฒฐํ–ˆ๋Š”๋ฐ,
์ฒซ ๋ฒˆ์งธ๋กœ ํ•ด๊ฒฐํ•œ ์—๋Ÿฌ๋Š” openAPI๋ฅผ ์ด์šฉํ•ด์„œ ๋‚ ์”จ ์˜ˆ๋ณด๋ฅผ ๋ถˆ๋Ÿฌ์˜ค์ง€ ๋ชปํ•˜๋Š” ์ ์„ ํ•ด๊ฒฐํ–ˆ๋‹ค.

Mixed Content: The page at 'https://hajoo0322.github.io/1week-project/' was loaded over HTTPS, 
but requested an insecure resource 'http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcst?serviceKey=YwQtuITGE24Cty%2BKIF1TkmtNgWiuGUKTCSB8cmqMKSDMRt8r8iq3wNheCCK5rUaTua8gArWcX4ZvS9dIq%2B%2FxiA%3D%3D&numOfRows=10&pageNo=1&dataType=JSON&base_date=20241107&base_time=0800&nx=60&ny=127'. 
This request has been blocked; the content must be served over HTTPS.

๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ค๋ฅ˜์˜€๋Š”๋ฐ ๊ตฌ๊ธ€๋ง๊ณผ GPT ์„ ์ƒ๋‹˜์—๊ฒŒ ๋ฌผ์–ด๋ณด๋‹ˆ HTTPS์™€ HTTP๊ฐ€ ์„œ๋กœ ๋งž์ง€ ์•Š์•„์„œ ๋ฐœ์ƒํ•˜๋Š” ์—๋Ÿฌ์˜€๋‹ค!

์—๋Ÿฌ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์„ ์ฐพ์€ ํ›„ ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•จ์œผ๋กœ์จ ์—๋Ÿฌ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

async function fetchWeatherData(nx, ny) {
    const apiKey = 'YwQtuITGE24Cty%2BKIF1TkmtNgWiuGUKTCSB8cmqMKSDMRt8r8iq3wNheCCK5rUaTua8gArWcX4ZvS9dIq%2B%2FxiA%3D%3D'; // ๋ณธ์ธ์˜ ์„œ๋น„์Šค ํ‚ค๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.
    const { date: baseDate, time: baseTime } = getCurrentDateTime();
    const url = `https://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcst?serviceKey=${apiKey}&numOfRows=1000&pageNo=1&dataType=JSON&base_date=${baseDate}&base_time=${baseTime}&nx=${nx}&ny=${ny}`;
    try {
        const response = await fetch(url);
        const data = await response.json();

        if (data.response.header.resultCode === "00") {
            displayForecast(data.response.body.items.item);
        } else {
            console.error("API ์‘๋‹ต ์˜ค๋ฅ˜: ", data.response.header.resultMsg);
        }
    } catch (error) {
        console.error("๋‚ ์”จ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: ", error);
    }
}

URL ์ฃผ์†Œ๋ฅผ ๋ฐ”๊ฟ”์ฃผ์—ˆ๋”๋‹ˆ ๋‚ ์”จ์˜ˆ๋ณด๊ฐ€ ์ž˜ ๋ถˆ๋Ÿฌ์™€์ง€๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

๋‹ค์Œ์œผ๋กœ ๋‘ ๋ฒˆ์งธ ์—๋Ÿฌ์˜€๋Š”๋ฐ.......
๋ฐฉ๋ช…๋ก ๊ธฐ๋Šฅ์„ ์ˆ˜์ •ํ•˜๊ณ  ๋‚˜๋‹ˆ๊นŒ ์ˆ˜์ •ํ•˜๊ธฐ ์ „์— ์ž‘์„ฑํ–ˆ์—ˆ๋˜ ๋ฐ์ดํ„ฐ๋“ค์ด ๋ถˆ๋Ÿฌ์™€์ง€์ง€ ์•Š๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ๋‹ค.................

๊ทธ๋ž˜์„œ ์ฝ”๋“œ์—์„œ ๋ฌธ์ œ๊ฐ€ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๊ณ  ๋ฐฉ๋ช…๋ก ๊ธฐ๋Šฅ ๊ตฌํ˜„ Javascript ์ฝ”๋“œ๋ฅผ ํ•˜๋‚˜ํ•˜๋‚˜ ์‚ดํŽด๋ดค๋‹ค.
์ฐจ๋ถ„ํ•˜๊ฒŒ ์‚ดํŽด๋ดค๋”๋‹ˆ ์ˆ˜์ •ํ•˜๊ธฐ ์ „์—๋Š” Timestamp ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•˜๋Š”๋ฐ ์ƒˆ๋กœ ์ˆ˜์ •ํ•˜๋ฉด์„œ Timestamp ๊ฐ’๋„ ๊ฐ™์ด Database์— ์ €์žฅ์ด ๋˜์—ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋ฐ์ดํ„ฐ๋ฅผ ๋ถˆ๋Ÿฌ์˜ฌ ๋•Œ๋„ Timestamp ๊ฐ’๋„ ๊ฐ™์ด ๊ฐ€์ ธ์™€์„œ ์ „์— ์ž‘์„ฑํ–ˆ๋˜ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ถˆ๋Ÿฌ์™€์ง€์ง€ ์•Š์•˜๋˜ ๊ฒƒ์ด์—ˆ๋‹ค...

์ตœ์‹  ์ˆœ์œผ๋กœ ์ •๋ ฌํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ–ˆ๋˜ ๊ฐœ๋…์ด์ง€๋งŒ ๋ฐฉ๋ช…๋ก์„ ์ˆœ์„œ๋Œ€๋กœ ๋‚˜์—ดํ•˜์ง€ ์•Š์•„๋„ ๋  ๊ฑฐ ๊ฐ™๋‹ค๋Š” ํŒ€์›๋“ค์˜ ์˜๊ฒฌ์œผ๋กœ Timestamp ๊ธฐ๋Šฅ์„ ์‚ญ์ œํ–ˆ๋”๋‹ˆ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๊ฐ€ ๋ฌด์‚ฌํžˆ ์ž˜๋‚˜์˜ค๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

๊ทธ ํ›„ ํŒ€์›๋“ค ๊ฐ์ž ๊ฐœ์ธ ํŽ˜์ด์ง€๋ฅผ ์ข€ ๋” ์—…๋ฐ์ดํŠธํ•˜๊ณ  ์ตœ์ข… ์ฃผ์†Œ๊นŒ์ง€ ๋ฐฐํฌํ–ˆ๋‹ค!!!!!!!!

ํŒ€์›๋“ค๊ณผ ํ•จ๊ป˜ ๋งŒ๋“  ํŽ˜์ด์ง€๊ฐ€ ๋ฐฐํฌ๊นŒ์ง€ ๋˜๊ณ  ๋‚˜๋‹ˆ ์—„์ฒญ ๋ฟŒ๋“ฏํ–ˆ๋‹ค ๐Ÿ˜Ž๐Ÿ˜Ž๐Ÿ˜Ž๐Ÿ˜Ž
๋‚ด์ผ ํ”„๋กœ์ ํŠธ ๋ฐœํ‘œ๊นŒ์ง€ ์ž˜ ๋งˆ๋ฌด๋ฆฌํ•  ์ˆ˜ ์žˆ์—ˆ์œผ๋ฉด ์ข‹๊ฒ ๋‹ค๐Ÿ˜ƒ๐Ÿ˜ƒ๐Ÿ˜ƒ 

 

ํ”„๋กœ์ ํŠธ ํ•˜๋ฉด์„œ ๋Š๋‚€ ์  ๐Ÿคจ 

ํ”„๋กœ์ ํŠธ๋ฅผ ์™„์„ฑํ•˜๊ณ  ์ตœ์ข… ๋ฐฐํฌ๊นŒ์ง€ ํ•˜๊ณ  ๋‚˜๋‹ˆ๊นŒ ์ฒซ ๋‹จ์ถ”๋ฅผ ์ž˜ ๊ฟฐ๋งจ ๊ฒƒ ๊ฐ™์€ ๋Š๋‚Œ์ด์—ˆ๋‹ค. ํŒ€์›๋“ค๊ณผ ํ˜‘์—…ํ•˜๋Š” ๊ณผ์ •๋„ ์ˆœ์กฐ๋กญ๊ฒŒ ํ˜๋Ÿฌ๊ฐ”๊ณ  ์„œ๋กœ ๋‹ค ์ž˜๋งž๋Š” ์‚ฌ๋žŒ๋“ค์ด์–ด์„œ ๋ฌธ์ œ ์—†์ด ํ”„๋กœ์ ํŠธ๊ฐ€ ์ง„ํ–‰๋  ์ˆ˜ ์žˆ์—ˆ๋˜ ๊ฒƒ ๊ฐ™๋‹ค.

Github์™€ ํŽ˜์ด์ง€๋ฅผ ๋งŒ๋“œ๋Š” ์ฝ”๋“œ๋ฅผ ์งœ๋Š” ๊ณผ์ •์—์„œ๋Š” ์—๋Ÿฌ์™€ ๋งˆ์ฃผํ•˜๊ณ  ํž˜๋„ ๋“ค์—ˆ์ง€๋งŒ ํ•˜๋‚˜์”ฉ ์ฐจ๊ทผ์ฐจ๊ทผ ์ฐพ์•„๋ณด๋ฉด์„œ ํ•ด๊ฒฐํ•˜๋‹ˆ๊นŒ ํ•ด๊ฒฐํ•  ์ˆ˜ ์—†๋Š” ์—๋Ÿฌ๋Š” ์—†์—ˆ๋‹ค!!!!

์•ž์œผ๋กœ๋„ ์ ˆ๋Œ€ ๋‹นํ™ฉํ•˜๊ฑฐ๋‚˜ ์งœ์ฆ...(?) ๋‚ด์ง€ ์•Š๊ณ  ์ฐจ๋ถ„ํ•˜๊ฒŒ ํ•˜๋‚˜์”ฉ ํ•ด๊ฒฐํ•˜๋ฉด์„œ ๊ณต๋ถ€ํ•˜๊ณ  ์„ฑ์žฅํ•ด์•ผ๊ฒ ๋‹ค ๐Ÿ˜ƒ๐Ÿ˜ƒ๐Ÿ˜ƒ