aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Powers <markppowers0@gmail.com>2019-02-01 13:02:50 -0500
committerMark Powers <markppowers0@gmail.com>2019-02-01 13:02:50 -0500
commitd1162d1bd12cbb3eae9889768adbbb293852c066 (patch)
treeb58fbf57426c9d789df088863991b7c106b08b7c
parent80ee170990e78753d07779d59bdfe516c399d254 (diff)
Remove /photo/ to uploads folder
-rw-r--r--.gitignore2
-rw-r--r--package-lock.json147
-rw-r--r--package.json2
-rw-r--r--src/html/admin.html36
-rw-r--r--src/html/bread.html2
-rw-r--r--src/html/index.html2
-rw-r--r--src/index.js3
-rw-r--r--src/photo/back.jpgbin1181073 -> 0 bytes
-rw-r--r--src/photo/ban1.jpgbin1106159 -> 0 bytes
-rw-r--r--src/photo/ban2.jpgbin1411456 -> 0 bytes
-rw-r--r--src/photo/cider.jpgbin725680 -> 0 bytes
-rw-r--r--src/photo/first-1.jpgbin283944 -> 0 bytes
-rw-r--r--src/photo/first-2.jpgbin296466 -> 0 bytes
-rw-r--r--src/photo/flat1.jpgbin1129498 -> 0 bytes
-rw-r--r--src/photo/flat2.jpgbin905668 -> 0 bytes
-rw-r--r--src/photo/good1.jpgbin241664 -> 0 bytes
-rw-r--r--src/photo/good2.jpgbin1847478 -> 0 bytes
-rw-r--r--src/photo/nyt1.jpgbin2142167 -> 0 bytes
-rw-r--r--src/photo/nyt2.jpgbin1286502 -> 0 bytes
-rw-r--r--src/photo/pizza1.jpgbin244008 -> 0 bytes
-rw-r--r--src/photo/pizza2.jpgbin1727783 -> 0 bytes
-rw-r--r--src/photo/pretty.jpgbin251665 -> 0 bytes
-rw-r--r--src/photo/wheat.jpgbin2669180 -> 0 bytes
-rw-r--r--src/photo/white-1.jpgbin1652366 -> 0 bytes
-rw-r--r--src/photo/white-2.jpgbin1811909 -> 0 bytes
-rw-r--r--src/server.js57
26 files changed, 242 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 67b12f5..e72625d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,3 +61,5 @@ typings/
.next
config.json
+uploads/
+
diff --git a/package-lock.json b/package-lock.json
index 114e4d0..2fe6214 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -34,6 +34,11 @@
"uri-js": "^4.2.2"
}
},
+ "append-field": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
+ "integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY="
+ },
"array-flatten": {
"version": "1.1.1",
"resolved": "http://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
@@ -102,6 +107,20 @@
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.1.3.tgz",
"integrity": "sha512-rDFIzgXcof0jDyjNosjv4Sno77X4KuPeFxG2XZZv1/Kc8DRVGVADdoQyyOVDwPqL36DDmtCQbrpMCqvpPLJQ0w=="
},
+ "buffer-from": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
+ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
+ },
+ "busboy": {
+ "version": "0.2.14",
+ "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz",
+ "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=",
+ "requires": {
+ "dicer": "0.2.5",
+ "readable-stream": "1.1.x"
+ }
+ },
"bytes": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",
@@ -129,6 +148,46 @@
"delayed-stream": "~1.0.0"
}
},
+ "concat-stream": {
+ "version": "1.6.2",
+ "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
+ "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
+ "requires": {
+ "buffer-from": "^1.0.0",
+ "inherits": "^2.0.3",
+ "readable-stream": "^2.2.2",
+ "typedarray": "^0.0.6"
+ },
+ "dependencies": {
+ "isarray": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
+ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
+ },
+ "readable-stream": {
+ "version": "2.3.6",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
+ "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
+ "requires": {
+ "core-util-is": "~1.0.0",
+ "inherits": "~2.0.3",
+ "isarray": "~1.0.0",
+ "process-nextick-args": "~2.0.0",
+ "safe-buffer": "~5.1.1",
+ "string_decoder": "~1.1.1",
+ "util-deprecate": "~1.0.1"
+ }
+ },
+ "string_decoder": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
+ "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
+ "requires": {
+ "safe-buffer": "~5.1.0"
+ }
+ }
+ }
+ },
"content-disposition": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz",
@@ -190,6 +249,15 @@
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
},
+ "dicer": {
+ "version": "0.2.5",
+ "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz",
+ "integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=",
+ "requires": {
+ "readable-stream": "1.1.x",
+ "streamsearch": "0.1.2"
+ }
+ },
"dottie": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.1.tgz",
@@ -414,6 +482,11 @@
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo="
},
+ "isarray": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
+ "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
+ },
"isstream": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
@@ -502,6 +575,19 @@
"mime-db": "~1.37.0"
}
},
+ "minimist": {
+ "version": "0.0.8",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
+ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
+ },
+ "mkdirp": {
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
+ "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
+ "requires": {
+ "minimist": "0.0.8"
+ }
+ },
"moment": {
"version": "2.24.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
@@ -520,6 +606,21 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
+ "multer": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.1.tgz",
+ "integrity": "sha512-zzOLNRxzszwd+61JFuAo0fxdQfvku12aNJgnla0AQ+hHxFmfc/B7jBVuPr5Rmvu46Jze/iJrFpSOsD7afO8SDw==",
+ "requires": {
+ "append-field": "^1.0.0",
+ "busboy": "^0.2.11",
+ "concat-stream": "^1.5.2",
+ "mkdirp": "^0.5.1",
+ "object-assign": "^4.1.1",
+ "on-finished": "^2.3.0",
+ "type-is": "^1.6.4",
+ "xtend": "^4.0.0"
+ }
+ },
"mysql2": {
"version": "1.6.4",
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-1.6.4.tgz",
@@ -570,6 +671,11 @@
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
"integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ=="
},
+ "object-assign": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
+ },
"on-finished": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
@@ -593,6 +699,11 @@
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
},
+ "process-nextick-args": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
+ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
+ },
"proxy-addr": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz",
@@ -638,6 +749,17 @@
"unpipe": "1.0.0"
}
},
+ "readable-stream": {
+ "version": "1.1.14",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
+ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
+ "requires": {
+ "core-util-is": "~1.0.0",
+ "inherits": "~2.0.1",
+ "isarray": "0.0.1",
+ "string_decoder": "~0.10.x"
+ }
+ },
"request": {
"version": "2.88.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz",
@@ -800,6 +922,16 @@
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
"integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew=="
},
+ "streamsearch": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
+ "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo="
+ },
+ "string_decoder": {
+ "version": "0.10.31",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
+ "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
+ },
"terraformer": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/terraformer/-/terraformer-1.0.9.tgz",
@@ -860,6 +992,11 @@
"mime-types": "~2.1.18"
}
},
+ "typedarray": {
+ "version": "0.0.6",
+ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
+ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
+ },
"unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
@@ -873,6 +1010,11 @@
"punycode": "^2.1.0"
}
},
+ "util-deprecate": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
+ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
+ },
"utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
@@ -916,6 +1058,11 @@
"@types/node": "*"
}
},
+ "xtend": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
+ "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
+ },
"yallist": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
diff --git a/package.json b/package.json
index 072b66b..716b581 100644
--- a/package.json
+++ b/package.json
@@ -10,8 +10,10 @@
"author": "",
"license": "ISC",
"dependencies": {
+ "body-parser": "^1.18.3",
"bootstrap": "^4.1.3",
"express": "^4.16.4",
+ "multer": "^1.4.1",
"mysql2": "^1.6.4",
"request": "^2.88.0",
"sequelize": "^4.42.0",
diff --git a/src/html/admin.html b/src/html/admin.html
new file mode 100644
index 0000000..7c87ba6
--- /dev/null
+++ b/src/html/admin.html
@@ -0,0 +1,36 @@
+<!doctype html>
+<html lang="en">
+
+<head>
+ <title>Mark's Kitchen - Admin</title>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+ <link rel="stylesheet" type="text/css" href="/css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="/css/styles.css">
+</head>
+
+<body>
+ <div>
+ <h1>Create Post</h1>
+ <div class="form">
+ <form action="/posts" method="post" enctype="multipart/form-data">
+ <div>
+ <textarea rows="4" cols="50" name="description"></textarea>
+ </div>
+ <div>
+ Images: <input type="file" name="images" multiple>
+ </div>
+ <div>
+ <select name="type">
+ <option value="" disabled selected>Select...</option>
+ <option value="bread">Bread</option>
+ <option value="index">Index</option>
+ </select>
+ </div>
+ <input type="submit">
+ </form>
+ </div>
+ </div>
+</body>
+
+</html> \ No newline at end of file
diff --git a/src/html/bread.html b/src/html/bread.html
index 8004803..e6eeb47 100644
--- a/src/html/bread.html
+++ b/src/html/bread.html
@@ -17,7 +17,7 @@
posts: []
},
created() {
- fetch(new Request('/bread/posts.json')).then(response => response.json())
+ fetch(new Request('/posts/bread')).then(response => response.json())
.then(response => this.posts = response.data);
}
});
diff --git a/src/html/index.html b/src/html/index.html
index 7a1d5d5..c7e398b 100644
--- a/src/html/index.html
+++ b/src/html/index.html
@@ -18,7 +18,7 @@
posts: []
},
created() {
- fetch(new Request('/index/posts.json')).then(response => response.json())
+ fetch(new Request('/posts/index')).then(response => response.json())
.then(response => this.posts = response.data);
}
});
diff --git a/src/index.js b/src/index.js
index fdcef74..b47824a 100644
--- a/src/index.js
+++ b/src/index.js
@@ -40,8 +40,7 @@ function setUpModels(){
type: {
type: Sequelize.STRING,
allowNull: false,
- },
- }),
+ },}),
"pictures": database.define('pictures', {
source: { type: Sequelize.TEXT, allowNull: false},
})
diff --git a/src/photo/back.jpg b/src/photo/back.jpg
deleted file mode 100644
index 9e8511e..0000000
--- a/src/photo/back.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/ban1.jpg b/src/photo/ban1.jpg
deleted file mode 100644
index 0330443..0000000
--- a/src/photo/ban1.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/ban2.jpg b/src/photo/ban2.jpg
deleted file mode 100644
index f868504..0000000
--- a/src/photo/ban2.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/cider.jpg b/src/photo/cider.jpg
deleted file mode 100644
index 176a094..0000000
--- a/src/photo/cider.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/first-1.jpg b/src/photo/first-1.jpg
deleted file mode 100644
index 664acd7..0000000
--- a/src/photo/first-1.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/first-2.jpg b/src/photo/first-2.jpg
deleted file mode 100644
index 11f2ab7..0000000
--- a/src/photo/first-2.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/flat1.jpg b/src/photo/flat1.jpg
deleted file mode 100644
index ff6df1c..0000000
--- a/src/photo/flat1.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/flat2.jpg b/src/photo/flat2.jpg
deleted file mode 100644
index d07f638..0000000
--- a/src/photo/flat2.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/good1.jpg b/src/photo/good1.jpg
deleted file mode 100644
index 3ff6e6b..0000000
--- a/src/photo/good1.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/good2.jpg b/src/photo/good2.jpg
deleted file mode 100644
index bec268d..0000000
--- a/src/photo/good2.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/nyt1.jpg b/src/photo/nyt1.jpg
deleted file mode 100644
index a31e79e..0000000
--- a/src/photo/nyt1.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/nyt2.jpg b/src/photo/nyt2.jpg
deleted file mode 100644
index 5c955da..0000000
--- a/src/photo/nyt2.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/pizza1.jpg b/src/photo/pizza1.jpg
deleted file mode 100644
index 051d5d0..0000000
--- a/src/photo/pizza1.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/pizza2.jpg b/src/photo/pizza2.jpg
deleted file mode 100644
index c5e9021..0000000
--- a/src/photo/pizza2.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/pretty.jpg b/src/photo/pretty.jpg
deleted file mode 100644
index 39afb35..0000000
--- a/src/photo/pretty.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/wheat.jpg b/src/photo/wheat.jpg
deleted file mode 100644
index b039eb6..0000000
--- a/src/photo/wheat.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/white-1.jpg b/src/photo/white-1.jpg
deleted file mode 100644
index a58d50b..0000000
--- a/src/photo/white-1.jpg
+++ /dev/null
Binary files differ
diff --git a/src/photo/white-2.jpg b/src/photo/white-2.jpg
deleted file mode 100644
index 87b8343..0000000
--- a/src/photo/white-2.jpg
+++ /dev/null
Binary files differ
diff --git a/src/server.js b/src/server.js
index 4a2a581..4cf76d1 100644
--- a/src/server.js
+++ b/src/server.js
@@ -1,9 +1,35 @@
const express = require('express');
+const bodyParser = require('body-parser');
const request = require('request');
+const multer = require('multer');
+var storage = multer.diskStorage({
+ destination: function (req, file, cb) {
+ cb(null, 'src/uploads/')
+ },
+ filename: function (req, file, cb) {
+ console.log(file);
+ var ext = "";
+ if(file.originalname.includes(".")){
+ ext = "." + file.originalname.split(".")[1];
+ console.log(ext);
+ }
+ console.log(ext);
+ return cb(null, 'img-' + Date.now()+ext)
+ }
+ })
+var upload = multer({ storage: storage })
+
const port = 80;
const server = express();
+// server.use(bodyParser.json());
+server.use(bodyParser.urlencoded({ extended: true }));
+server.use(function (req, res, next) {
+ console.debug("express:", req.method, req.originalUrl);
+ next()
+})
+
function listen(){
server.listen(port, () => console.info(`Listening on port ${port}!`));
@@ -11,6 +37,8 @@ function listen(){
function setUpRoutes(models){
server.get('/', (req, res) => res.sendFile(__dirname + "/html/index.html"))
+ server.get('/index', (req, res) => res.sendFile(__dirname + "/html/index.html"))
+ server.get('/admin', (req, res) => res.sendFile(__dirname + "/html/admin.html"));
server.get('/bread', (req, res) => res.sendFile(__dirname + "/html/bread.html"));
server.get('/essay', (req, res) => res.sendFile(__dirname + "/html/essay.html"));
server.get('/snake', (req, res) => res.sendFile(__dirname + "/html/snake.html"));
@@ -18,15 +46,13 @@ function setUpRoutes(models){
request(`http://localhost:8000?${req.url.split("?")[1]}`, function(error, response, body) {
});
})
- server.get('/:type/posts.json', async (req, res, next) => {
+ server.get('/posts/:type', async (req, res, next) => {
try {
const { type } = req.params;
- console.log(type);
- console.log(req.params);
- var posts = await models.posts.findAll({where: { type: type }});
+ var posts = await models.posts.findAll({where: { type: type }, order: [['createdAt', 'DESC']]});
posts = posts.map(x => x.get({ plain: true }));
for (const post of posts) {
- const images = await models.pictures.findAll({ attributes: ["source"], where: { postId: post.id } }).map(x => x.source);
+ const images = await models.pictures.findAll({ attributes: ["source"], where: { postId: post.id }}).map(x => x.source);
post.images = images;
}
res.status(200).send({ success: true, data: posts });
@@ -35,6 +61,23 @@ function setUpRoutes(models){
res.status(400).send({ success: false, error: e.message });
}
})
+ server.post('/posts', upload.array('images'), async (req, res, next) => {
+ try {
+ console.log(req.body);
+
+ const type = req.body.type
+ const newPost = await models.posts.create(req.body);
+ req.files.forEach(async (file) => {
+ await models.pictures.create({"source": "uploads/"+file.filename, "postId": newPost.id});
+ console.log("uploaded ", file.path);
+ })
+ console.log(newPost);
+ res.redirect(`/${type}`);
+ next();
+ } catch (e) {
+ res.status(400).send({ success: false, error: e.message });
+ }
+ })
server.get('/favicon.ico', (req, res) => res.sendFile(__dirname + "/icon/favicon.ico"))
@@ -42,8 +85,12 @@ function setUpRoutes(models){
res.sendFile(__dirname + "/css/"+req.params.id);
});
server.get('/photo/:id', (req, res) => {
+ // res.setHeater("Content-Type", "image")
res.sendFile(__dirname + "/photo/"+req.params.id);
});
+ server.get('/uploads/:id', (req, res) => {
+ res.sendFile(__dirname + "/uploads/"+req.params.id);
+ });
server.get('/essay/:id', (req, res) => {
res.sendFile(__dirname + "/html/essay/"+req.params.id);
});