이민호

confirm exception handling

var express = require("express");
var router = express.Router();
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var result = "";
var characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
for (var i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
......@@ -15,19 +16,28 @@ var rekognition = new AWS.Rekognition();
/* GET home page. */
router.get("/", function (req, res, next) {
var collectionID = makeid(8)
var collectionID = makeid(8);
var params = {
CollectionId: collectionID
};
rekognition.createCollection(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
console.log(collectionID)
res.render("index", { title: "Express", error:"",collection: collectionID});
CollectionId: collectionID,
};
rekognition.createCollection(params, function (err, data) {
if (err) console.log(err, err.stack);
// an error occurred
else console.log(data); // successful response
});
console.log(collectionID);
res.render("index", {
title: "AI Screensaver",
error: "",
collection: collectionID,
});
});
router.post("/", function (req, res, next){
console.log(req.body.collection)
res.render("index", { title: "Express", error:"",collection: req.body.collection});
router.post("/", function (req, res, next) {
console.log(req.body.collection);
res.render("index", {
title: "AI Screensaver",
error: "",
collection: req.body.collection,
});
});
module.exports = router;
......
<h1><%= message %></h1>
<h2><%= error.status %></h2>
<pre><%= error.stack %></pre>
<!-- <pre><%= error.stack %></pre> -->
<a href="/"> go back to home </a>
......
......@@ -41,7 +41,7 @@
<form action=/register method="post" enctype="multipart/form-data">
<input type="file" id="img" name="img" accept="image/png, image/jpeg" class="button alt">
<input type='hidden' name="collection" id='collection' value="<%= collection %>" >
<input type="text" id="image_id" name="text" value="사진 이름""><input type="submit" value="등록" class="button alt"">
<input type="text" id="image_id" name="text" placeholder="사진 이름" required><input type="submit" value="등록" class="button alt"">
</form>
</footer>
</div>
......