2 글 보임 - 1 에서 2 까지 (총 2 중에서)
-
글쓴이글
-
2023년 1월 21일 15:53 #63650
정중식참가자app.get('/', function (req, res) { res.render('index.ejs'); });
app.get('/write', function (req, res) { res.render('write.ejs'); });
app.post('/add', function (req, res) { db.collection('counter').findOne( { name: '게시물갯수' }, function (err, result) { var totalPost = result.totalPost;
db.collection('post').insertOne( { _id: totalPost + 1, title: req.body.title, date: req.body.date }, function (err, res) { console.log('저장완료');
db.collection('counter').updateOne( { name: '게시물갯수' }, { $inc: { totalPost: 1 } }, function (err, result) { if (err) { return console.log(err); } } ); } ); return res.redirect('/list'); } ); });
app.get('/list', function (req, res) { db.collection('post') .find() .toArray(function (err, result) { res.render('list.ejs', { posts: result }); });
app.delete('/delete', function (req, res) { const id = parseInt(req.body._id); db.collection('post').deleteOne({ _id: id }, function (err, result) { res.status(200).send('성공'); }); });
app.get('/edit', function (req, res) { res.render('edit.ejs'); });
app.get('/detail/:id', function (req, res) { // console.log(req.params.id); db.collection('post').findOne( { _id: parseInt(req.params.id) }, function (err, data) { if (!data) { return res.status(404).send('not found'); } else { res.render('detail.ejs', { data }); } } ); }); 위는 전체 코드입니다. 문제는 app.get('/edit', function (req, res) { res.render('edit.ejs'); }); 이 코드를
이렇게 '/' 경로 아래에다 깔아두면 url에 /edit를 치면 잘들어가지는데 위의 전체 코드처럼 '/' 코드 바로 아래에다 안깔고 중간에 코드를 작성해두면 경로에 안들어가집니다. Cannot GET /edit 라는 문구가 페이지에 출력되구요 에러메시지로는 GET http://localhost:8080/edit 404 (Not Found) 9Refused to load the font '<URL>' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'font-src' was not explicitly set, so 'default-src' is used as a fallback. 이런 문구가 뜹니다 혹시 이럴땐 어떻게 해줘야할까요?
-
글쓴이글
2 글 보임 - 1 에서 2 까지 (총 2 중에서)
- 답변은 로그인 후 가능합니다.