-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
137 additions
and
20 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// src/pages/api/alarm.js | ||
|
||
import axios from 'axios'; | ||
|
||
export default async function handler(req, res) { | ||
try { | ||
|
||
if (req.method === 'GET') { | ||
// GET 요청: 센서 데이터를 조회하여 클라이언트에 응답 | ||
const response = await axios.get('http://localhost:8089/api/alarm'); | ||
const alarm_t = response.data; | ||
res.status(200).json({ alarm_t }); | ||
} else if (req.method === 'POST') { | ||
// POST 요청: 클라이언트로부터 받은 센서 정보를 데이터베이스에 추가 | ||
const { alarm_type, alarm_time, alarm_read } = req.body; | ||
await axios.post('http://localhost:8089/api/alarm', | ||
{ | ||
alarm_type: alarm_type, | ||
alarm_time: alarm_time, | ||
alarm_read: alarm_read, | ||
}); | ||
console.log('데이터가 성공적으로 전송되었습니다.'); | ||
} else { | ||
res.status(405).json({ message: 'Method Not Allowed' }); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
res.status(500).json({ message: 'Internal Server Error' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// src/pages/api/sensing.js | ||
//목표온도 계산하려고 | ||
|
||
import axios from 'axios'; | ||
|
||
export default async function handler(req, res) { | ||
try { | ||
|
||
if (req.method === 'GET') { | ||
// GET 요청: 센서 데이터를 조회하여 클라이언트에 응답 | ||
const response = await axios.get('http://localhost:8089/api/sensing'); | ||
const sensing_t = response.data; | ||
res.status(200).json({ sensing_t }); | ||
} else if (req.method === 'POST') { | ||
// POST 요청: 클라이언트로부터 받은 센서 정보를 데이터베이스에 추가 | ||
const { sensing_time, sensing_goal, sensing_data, curing_date } = req.body; | ||
await axios.post('http://localhost:8089/api/sensing', | ||
{ | ||
sensing_time: sensing_time, | ||
sensing_goal: sensing_goal, | ||
sensing_data: sensing_data, | ||
curing_date: curing_date, | ||
}); | ||
console.log('데이터가 성공적으로 전송되었습니다.'); | ||
} else { | ||
res.status(405).json({ message: 'Method Not Allowed' }); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
res.status(500).json({ message: 'Internal Server Error' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// src/pages/api/data_sensor.js | ||
// src/pages/api/site.js | ||
|
||
import axios from 'axios'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters