Flare-k

[Modify] Upload router & Logout router

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