Flare-k

[Modify] Upload router & Logout router

...@@ -23,8 +23,16 @@ export const getLogin = (req, res) => ...@@ -23,8 +23,16 @@ export const getLogin = (req, res) =>
23 export const postLogin = (req, res) => { 23 export const postLogin = (req, res) => {
24 res.redirect(routes.home); 24 res.redirect(routes.home);
25 }; 25 };
26 -export const logout = (req, res) => 26 +
27 - res.render("logout", { pageTitle: "Logout" }); 27 +//로그아웃을 클릭하면 LogOut페이지로 가는 것 대신에, 로그아웃을 처리한 후
28 +// home 페이지로 Redirect로 표현할 것이다.
29 +//즉, 초반에 만들어둔 logout.pug는 삭제해도 좋다.
30 +export const logout = (req, res) => {
31 + //res.render("logout", { pageTitle: "Logout" });
32 + res.redirect(routes.home);
33 +};
34 +
35 +
28 export const users = (req, res) => res.render("users", { pageTitle: "Users" }); 36 export const users = (req, res) => res.render("users", { pageTitle: "Users" });
29 export const userDetail = (req, res) => 37 export const userDetail = (req, res) =>
30 res.render("userDetail", { pageTitle: "User Detail" }); 38 res.render("userDetail", { pageTitle: "User Detail" });
......
1 import { videos } from "../db"; 1 import { videos } from "../db";
2 +import routes from "../routes";
3 +
2 export const home = (req, res) => { 4 export const home = (req, res) => {
3 res.render("home", { pageTitle: "Home", videos }); 5 res.render("home", { pageTitle: "Home", videos });
4 }; 6 };
...@@ -10,7 +12,19 @@ export const search = (req, res) => { ...@@ -10,7 +12,19 @@ export const search = (req, res) => {
10 res.render("search", { pageTitle: "Search", searchingBy, videos }); 12 res.render("search", { pageTitle: "Search", searchingBy, videos });
11 }; 13 };
12 14
13 -export const upload = (req, res) => res.render("upload", { pageTitle: "Upload" }); 15 +//upload 또한 upload를 준비하기 위한 get 페이지와 실제 데이터를 보내는 post 페이지가 필요하다.
16 +export const getUpload = (req, res) =>
17 + res.render("upload", { pageTitle: "Upload" });
18 +export const postUpload = (req, res) => {
19 + //const {} 를 통해 body를 받아와 요청하는 정보들을 확인한다.
20 + //이는 pug와 db.js를 확인해야하는 듯 하다.
21 + const {
22 + body: { file, title, description },
23 + } = req;
24 + res.redirect(routes.videoDetail(324393));
25 +};
26 +
27 +
14 export const videoDetail = (req, res) => res.render("videoDetail", { pageTitle: "Video Detail" }); 28 export const videoDetail = (req, res) => res.render("videoDetail", { pageTitle: "Video Detail" });
15 export const editVideo = (req, res) => res.render("editVideo", { pageTitle: "Edit Video" }); 29 export const editVideo = (req, res) => res.render("editVideo", { pageTitle: "Edit Video" });
16 export const deleteVideo = (req, res) => res.render("deleteVideo", { pageTitle: "Delete Video" }); 30 export const deleteVideo = (req, res) => res.render("deleteVideo", { pageTitle: "Delete Video" });
...\ No newline at end of file ...\ No newline at end of file
......
1 import express from "express"; 1 import express from "express";
2 import routes from "../routes"; 2 import routes from "../routes";
3 import { 3 import {
4 - upload, 4 + getUpload,
5 + postUpload,
5 videoDetail, 6 videoDetail,
6 editVideo, 7 editVideo,
7 deleteVideo, 8 deleteVideo,
...@@ -9,7 +10,9 @@ import { ...@@ -9,7 +10,9 @@ import {
9 //export const videoRouter = express.Router(); 이렇게하면 이 변수만 export하게 된다. 10 //export const videoRouter = express.Router(); 이렇게하면 이 변수만 export하게 된다.
10 const videoRouter = express.Router(); 11 const videoRouter = express.Router();
11 12
12 -videoRouter.get(routes.upload, upload); 13 +videoRouter.get(routes.upload, getUpload);
14 +videoRouter.post(routes.upload, postUpload);
15 +
13 16
14 videoRouter.get(routes.editVideo, editVideo); 17 videoRouter.get(routes.editVideo, editVideo);
15 18
......
...@@ -3,7 +3,7 @@ extends layouts/main ...@@ -3,7 +3,7 @@ extends layouts/main
3 block content 3 block content
4 .form-container 4 .form-container
5 form(action=routes.login, method="post") 5 form(action=routes.login, method="post")
6 - input(type="email", name="email", placeholder="Email") 6 + input(type="email", name="email", placeholder="Email", required=true)
7 - input(type="password", name="password", placeholder="Password") 7 + input(type="password", name="password", placeholder="Password", required=true)
8 input(type="submit", value="Log In") 8 input(type="submit", value="Log In")
9 include partials/socialLogin 9 include partials/socialLogin
...\ No newline at end of file ...\ No newline at end of file
......
1 -extends layouts/main
2 -
3 -block content
4 - p Hello This is Logout
...\ No newline at end of file ...\ No newline at end of file
...@@ -4,7 +4,7 @@ block content ...@@ -4,7 +4,7 @@ block content
4 .form-container 4 .form-container
5 form(action=`/videos${routes.upload}`, method="post") 5 form(action=`/videos${routes.upload}`, method="post")
6 label(for="file") Video File 6 label(for="file") Video File
7 - input(type="file", id="file", name="file") 7 + input(type="file", id="file", name="file", required=true)
8 - input(type="text", placeholder="Title", name="title") 8 + input(type="text", placeholder="Title", name="title", required=true)
9 - textarea(name="description", placeholder="Description") 9 + textarea(name="description", placeholder="Description", required=true)
10 input(type="submit", value="Upload Video") 10 input(type="submit", value="Upload Video")
...\ No newline at end of file ...\ No newline at end of file
......