Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[과제] 모각코 6조 조현우 과제 제출 #6

Open
wants to merge 5 commits into
base: mogako-team-6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,22 @@
- 장소 : 국민대학교 미래관 445호
- 주제 : `1. Server - Node.js와 EXPRESS.JS 입문`
- 강의 자료 : <a href="./week2-1"> 링크 </a>
- 과제 제출 : <a href=""> 링크 </a>
- 과제 제출 : <a href="https://github.com/kmu-koss/2023-1_IoT_Study/issues/4"> 링크 </a>

## 과제 제출 - GitHub

### 과제 제출 방법
과제를 제출할 때에는 다음과 같이 제출합니다.
1. 자신의 모각코 조의 Branch Repository를 Fork합니다.
1. 해당 Repository를 Fork합니다.
<img src="./src/fork.png">

2. 과제를 완성하고, 자신의 모각코 조의 Branch에 Pull Requset를 건다.
<img src="./src/pullrequest.png">

3. 단, Pull Request를 걸때, #1과 같이 과제 번호와 연결한다.
<img src="./src/pullrequest2.png">

---

### 온라인 질문 방법
스터디 시간 이외에 하고 싶은 질문이 있다면 Issue를 통하여 질문을 올려주시면 됩니다! <br>
Expand Down
38 changes: 38 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const express = require("express");
const cors = require("cors");
const bodyParser = require("body-parser");

const app = express();
const PORT = 8000;
app.use(bodyParser.json());

const corsOptions = {
origin: "http://localhost:3000",
credentials: true,
};
app.use(cors(corsOptions));

app.get("/", (req, res) => {
ymw0407 marked this conversation as resolved.
Show resolved Hide resolved
res.send("home");
});

app.get("/dust", (req, res) => {
res.json([
{ team: "모각코 6조", value: "1000" },
{ team: "모각코 2조", value: "38" },
]);
});

app.patch("/toggle", (req, res) => {
const { toggle } = req.body;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

구조 분해 할당 잘 쓴거 같아!!

if (toggle == "ON") {
res.json({ toggle: "OFF" });
} else if (toggle == "OFF") {
res.json({ toggle: "ON" });
}
});

app.listen(PORT, () => {
console.log(`server start on port: ${PORT}`);
});

Loading