Showing
3 changed files
with
28 additions
and
18 deletions
1 | var express = require("express"); | 1 | var express = require("express"); |
2 | var router = express.Router(); | 2 | var router = express.Router(); |
3 | function makeid(length) { | 3 | function makeid(length) { |
4 | - var result = ''; | 4 | + var result = ""; |
5 | - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | 5 | + var characters = |
6 | + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
6 | var charactersLength = characters.length; | 7 | var charactersLength = characters.length; |
7 | - for ( var i = 0; i < length; i++ ) { | 8 | + for (var i = 0; i < length; i++) { |
8 | - result += characters.charAt(Math.floor(Math.random() * charactersLength)); | 9 | + result += characters.charAt(Math.floor(Math.random() * charactersLength)); |
9 | } | 10 | } |
10 | return result; | 11 | return result; |
11 | } | 12 | } |
... | @@ -15,19 +16,28 @@ var rekognition = new AWS.Rekognition(); | ... | @@ -15,19 +16,28 @@ var rekognition = new AWS.Rekognition(); |
15 | 16 | ||
16 | /* GET home page. */ | 17 | /* GET home page. */ |
17 | router.get("/", function (req, res, next) { | 18 | router.get("/", function (req, res, next) { |
18 | - var collectionID = makeid(8) | 19 | + var collectionID = makeid(8); |
19 | var params = { | 20 | var params = { |
20 | - CollectionId: collectionID | 21 | + CollectionId: collectionID, |
21 | - }; | 22 | + }; |
22 | - rekognition.createCollection(params, function(err, data) { | 23 | + rekognition.createCollection(params, function (err, data) { |
23 | - if (err) console.log(err, err.stack); // an error occurred | 24 | + if (err) console.log(err, err.stack); |
24 | - else console.log(data); // successful response | 25 | + // an error occurred |
25 | - }); | 26 | + else console.log(data); // successful response |
26 | - console.log(collectionID) | 27 | + }); |
27 | - res.render("index", { title: "Express", error:"",collection: collectionID}); | 28 | + console.log(collectionID); |
29 | + res.render("index", { | ||
30 | + title: "AI Screensaver", | ||
31 | + error: "", | ||
32 | + collection: collectionID, | ||
33 | + }); | ||
28 | }); | 34 | }); |
29 | -router.post("/", function (req, res, next){ | 35 | +router.post("/", function (req, res, next) { |
30 | - console.log(req.body.collection) | 36 | + console.log(req.body.collection); |
31 | - res.render("index", { title: "Express", error:"",collection: req.body.collection}); | 37 | + res.render("index", { |
38 | + title: "AI Screensaver", | ||
39 | + error: "", | ||
40 | + collection: req.body.collection, | ||
41 | + }); | ||
32 | }); | 42 | }); |
33 | module.exports = router; | 43 | module.exports = router; | ... | ... |
... | @@ -41,7 +41,7 @@ | ... | @@ -41,7 +41,7 @@ |
41 | <form action=/register method="post" enctype="multipart/form-data"> | 41 | <form action=/register method="post" enctype="multipart/form-data"> |
42 | <input type="file" id="img" name="img" accept="image/png, image/jpeg" class="button alt"> | 42 | <input type="file" id="img" name="img" accept="image/png, image/jpeg" class="button alt"> |
43 | <input type='hidden' name="collection" id='collection' value="<%= collection %>" > | 43 | <input type='hidden' name="collection" id='collection' value="<%= collection %>" > |
44 | - <input type="text" id="image_id" name="text" value="사진 이름""><input type="submit" value="등록" class="button alt""> | 44 | + <input type="text" id="image_id" name="text" placeholder="사진 이름" required><input type="submit" value="등록" class="button alt""> |
45 | </form> | 45 | </form> |
46 | </footer> | 46 | </footer> |
47 | </div> | 47 | </div> | ... | ... |
-
Please register or login to post a comment