lauraF
3 years ago
5 changed files with 110 additions and 109 deletions
-
63access.log
-
4app.js
-
40controllers/blogController.js
-
24public/models/blog.json
-
88routes/blog.js
@ -0,0 +1,63 @@ |
|||||
|
::1 - - [16/May/2022:14:36:33 +0000] "POST /blog HTTP/1.1" 200 4090 "http://localhost/blog/newPost" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:36:33 +0000] "GET /stylesheets/bootstrap.min.css HTTP/1.1" 304 - "http://localhost/blog" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:36:33 +0000] "GET /javascripts/bootstrap.bundle.min.js HTTP/1.1" 304 - "http://localhost/blog" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:36:33 +0000] "GET /stylesheets/style.css HTTP/1.1" 304 - "http://localhost/blog" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:36:33 +0000] "GET /images/logo.PNG HTTP/1.1" 304 - "http://localhost/blog" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:36:36 +0000] "POST /blog HTTP/1.1" 200 4090 "http://localhost/blog" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:36:36 +0000] "GET /stylesheets/bootstrap.min.css HTTP/1.1" 304 - "http://localhost/blog" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:36:36 +0000] "GET /javascripts/bootstrap.bundle.min.js HTTP/1.1" 304 - "http://localhost/blog" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:36:36 +0000] "GET /stylesheets/style.css HTTP/1.1" 304 - "http://localhost/blog" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:36:36 +0000] "GET /images/logo.PNG HTTP/1.1" 304 - "http://localhost/blog" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:36:38 +0000] "GET /blog HTTP/1.1" 200 286 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:36:47 +0000] "GET /blog/:3 HTTP/1.1" - - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:36:50 +0000] "GET /blog/3 HTTP/1.1" - - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:40:55 +0000] "GET /blog/:3 HTTP/1.1" - - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:40:57 +0000] "GET /blog/:3 HTTP/1.1" - - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:41:00 +0000] "GET /blog/3 HTTP/1.1" - - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::ffff:127.0.0.1 - - [16/May/2022:14:43:19 +0000] "GET /blog/:3 HTTP/1.1" 500 1283 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:43:26 +0000] "GET /blog/ HTTP/1.1" 200 286 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:43:29 +0000] "GET /blog/:3 HTTP/1.1" 500 1283 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:43:30 +0000] "GET /blog/:3 HTTP/1.1" 500 1283 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:44:13 +0000] "GET /blog/:3 HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:44:17 +0000] "GET /blog/:2 HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:44:20 +0000] "GET /blog/:1 HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:44:57 +0000] "GET /blog/:1 HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:45:20 +0000] "GET /blog/ HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:47:43 +0000] "GET /blog/ HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:47:47 +0000] "GET /blog/:3 HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:47:50 +0000] "GET /blog/:2 HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:48:07 +0000] "GET /blog/:2 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:48:10 +0000] "GET /blog/:1 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:48:10 +0000] "GET /blog/:1 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:48:24 +0000] "GET /blog/:1 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:49:17 +0000] "GET /blog/:1 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:49:20 +0000] "GET /blog/:2 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:52:46 +0000] "GET /blog/:2 HTTP/1.1" 200 58 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:53:13 +0000] "GET /blog/:2 HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:53:15 +0000] "GET /blog/:1 HTTP/1.1" 200 58 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:53:18 +0000] "GET /blog/:3 HTTP/1.1" 200 58 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:53:18 +0000] "GET /blog/:3 HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:53:32 +0000] "GET /blog/:3 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:53:52 +0000] "GET /blog/:3 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:54:07 +0000] "GET /blog/:3 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:54:14 +0000] "GET /blog/3 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:54:14 +0000] "GET /blog/3 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:54:27 +0000] "GET /blog/2 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:55:51 +0000] "GET /blog/newPost HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:55:51 +0000] "GET /stylesheets/bootstrap.min.css HTTP/1.1" 304 - "http://localhost/blog/newPost" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:55:51 +0000] "GET /javascripts/bootstrap.bundle.min.js HTTP/1.1" 304 - "http://localhost/blog/newPost" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:55:51 +0000] "GET /stylesheets/style.css HTTP/1.1" 304 - "http://localhost/blog/newPost" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:55:51 +0000] "GET /images/logo.PNG HTTP/1.1" 304 - "http://localhost/blog/newPost" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:55:54 +0000] "GET /blog/newPost HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:55:54 +0000] "GET /javascripts/bootstrap.bundle.min.js HTTP/1.1" 304 - "http://localhost/blog/newPost" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:55:54 +0000] "GET /images/logo.PNG HTTP/1.1" 304 - "http://localhost/blog/newPost" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:56:31 +0000] "GET /blog/newPost HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:56:31 +0000] "GET /stylesheets/bootstrap.min.css HTTP/1.1" 304 - "http://localhost/blog/newPost" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:56:31 +0000] "GET /javascripts/bootstrap.bundle.min.js HTTP/1.1" 304 - "http://localhost/blog/newPost" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:56:31 +0000] "GET /stylesheets/style.css HTTP/1.1" 304 - "http://localhost/blog/newPost" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:56:31 +0000] "GET /images/logo.PNG HTTP/1.1" 304 - "http://localhost/blog/newPost" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:56:33 +0000] "GET /blog/3 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:57:21 +0000] "GET /blog/3 HTTP/1.1" 200 70 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:57:24 +0000] "GET /blog/2 HTTP/1.1" 200 58 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:57:27 +0000] "GET /blog/1 HTTP/1.1" 200 68 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
||||
|
::1 - - [16/May/2022:14:57:29 +0000] "GET /blog/5 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59" |
@ -1,18 +1,30 @@ |
|||||
[ |
[ |
||||
{ |
{ |
||||
"id": 1, |
"id": 1, |
||||
"title": "titel", |
|
||||
|
"title": "Titel 3", |
||||
"username": "name", |
"username": "name", |
||||
"date": "", |
"date": "", |
||||
"text": "text", |
|
||||
"file": "" |
|
||||
|
"text": "Text" |
||||
}, |
}, |
||||
{ |
{ |
||||
"id": 2, |
"id": 2, |
||||
"title": "titel", |
|
||||
|
"title": "4", |
||||
"username": "", |
"username": "", |
||||
"date": "", |
"date": "", |
||||
"text": "", |
|
||||
"file": "" |
|
||||
|
"text": "rrde" |
||||
|
}, |
||||
|
{ |
||||
|
"id": 3, |
||||
|
"title": "titel eines blogs", |
||||
|
"username": "", |
||||
|
"date": "", |
||||
|
"text": "" |
||||
|
}, |
||||
|
{ |
||||
|
"id": 4, |
||||
|
"title": "und noch ein Blog", |
||||
|
"username": "", |
||||
|
"date": "", |
||||
|
"text": "" |
||||
} |
} |
||||
] |
] |
@ -1,96 +1,22 @@ |
|||||
var express = require('express'); |
var express = require('express'); |
||||
let res = require('express/lib/response'); |
let res = require('express/lib/response'); |
||||
var router = express.Router(); |
var router = express.Router(); |
||||
//fileStream ermöglicht Lesen und Schreiben auf Festplatte
|
|
||||
var fs = require('fs'); |
|
||||
const { ServerResponse } = require('http'); |
|
||||
|
|
||||
//let blog = [];
|
|
||||
|
|
||||
//erstellt JSONObjekt
|
|
||||
let rawdata = fs.readFileSync('./public/models/blog.json'); |
|
||||
//wandelt JSONObjekt in JsObjekt
|
|
||||
let blogInhalt = JSON.parse(rawdata); |
|
||||
|
var blogControllers = require('../controllers/blogController'); |
||||
|
|
||||
/* GET home page. */ |
/* GET home page. */ |
||||
router.route('/') |
router.route('/') |
||||
.get((req, res, next) => { // => Pfeilfunktion: ersetzt function()
|
|
||||
for (i = 0; i < blogInhalt.length; i++) { |
|
||||
console.log(blogInhalt[i].id, ".", blogInhalt[i].title); |
|
||||
} |
|
||||
res.send({ blogInhalt }); |
|
||||
}) |
|
||||
.post((req, res, next) => { |
|
||||
|
|
||||
/*let blogeintrag = []; |
|
||||
let title = req.body.title; |
|
||||
let username = req.body.username; |
|
||||
let date = req.body.date; |
|
||||
let text = req.body.text; |
|
||||
console.log(title); |
|
||||
blogeintrag.push(title, username, date, text); |
|
||||
blog.push(blogeintrag); */ |
|
||||
let blogID; |
|
||||
|
|
||||
if (blogInhalt.length == 0) { |
|
||||
blogID = 1; |
|
||||
} else { |
|
||||
blogID = (blogInhalt[blogInhalt.length - 1].id) + 1; |
|
||||
} |
|
||||
|
|
||||
try { |
|
||||
if (!req.body.file) { |
|
||||
res.send({ |
|
||||
status: false, |
|
||||
message: "No file received" |
|
||||
}); |
|
||||
} else { |
|
||||
let file = req.body.file; |
|
||||
file.mv('./uploads/' + file.name); |
|
||||
res.send('freude...' + file.name); |
|
||||
console.log("Datei empfangen"); |
|
||||
} |
|
||||
} catch (err) { |
|
||||
res.status(500).send(err); |
|
||||
} |
|
||||
|
|
||||
let blogeintrag = { |
|
||||
id: blogID, |
|
||||
title: req.body.title, |
|
||||
username: req.body.username, |
|
||||
date: req.body.date, |
|
||||
text: req.body.text, |
|
||||
file: req.body.file |
|
||||
} |
|
||||
|
|
||||
console.log(blogeintrag); |
|
||||
|
|
||||
//hänge blogeintrag an blogInhalt
|
|
||||
blogInhalt.push(blogeintrag); |
|
||||
|
|
||||
let date = JSON.stringify(blogInhalt, null, 2); |
|
||||
|
|
||||
fs.writeFileSync('./public/models/blog.json', date); |
|
||||
|
|
||||
res.render('blogPost', { title: 'Nächster Post' }) |
|
||||
}); |
|
||||
|
.get(blogControllers.getAllPosts) |
||||
|
.post(blogControllers.createPost); |
||||
|
|
||||
router.get('/newPost', function (req, res, next) { |
router.get('/newPost', function (req, res, next) { |
||||
res.render('blogPost', { title: 'BlogEintrag' }); |
res.render('blogPost', { title: 'BlogEintrag' }); |
||||
}); |
}); |
||||
|
|
||||
router.get('/:postID', function (req, res, next) { |
|
||||
let blogID = req.params.postID; |
|
||||
|
|
||||
for (i = 0; i < blogInhalt.length; i++) { |
|
||||
if (blogInhalt[i].id == blogID) { |
|
||||
console.log(blogInhalt[i].id, blogInhalt[i].title); |
|
||||
res.send({ ID: blogInhalt[i].id, Titel: blogInhalt[i].title }); |
|
||||
} |
|
||||
} |
|
||||
res.send({ "text: ": "Kein entsprechender Eintrag gefunden!" }) |
|
||||
console.log('Kein entsprechender Eintrag gefunden.'); |
|
||||
|
router.route('/:postID') |
||||
|
.get(blogControllers.getPost); |
||||
|
|
||||
|
router.get('/:postID', function (req, res, next) { |
||||
|
blogControllers.getPost; |
||||
}); |
}); |
||||
|
|
||||
module.exports = router; |
module.exports = router; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue