Toggle navigation
Toggle navigation
This project
Loading...
Sign in
seungmin lee
/
OSS2020-2_Screensaver
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이민호
2020-12-07 00:50:30 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
91aaecff246a293fae973ac2a2ce069d3bce08aa
91aaecff
1 parent
d2c3bfab
confirm exception handling
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
14 deletions
screensaver/routes/index.js
screensaver/views/error.ejs
screensaver/views/index.ejs
screensaver/routes/index.js
View file @
91aaecf
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
++
)
{
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
CollectionId
:
collectionID
,
};
rekognition
.
createCollection
(
params
,
function
(
err
,
data
)
{
if
(
err
)
console
.
log
(
err
,
err
.
stack
);
// an error occurred
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
});
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
;
...
...
screensaver/views/error.ejs
View file @
91aaecf
<h1><%= message %></h1>
<h2><%= error.status %></h2>
<
pre><%= error.stack %></pre
>
<
!-- <pre><%= error.stack %></pre> --
>
<a href="/"> go back to home </a>
...
...
screensaver/views/index.ejs
View file @
91aaecf
...
...
@@ -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>
...
...
Please
register
or
login
to post a comment