Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
nodejs-60-2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jatuporn Tonggasem
nodejs-60-2
Commits
8deb2831
Commit
8deb2831
authored
Mar 28, 2018
by
jatuporn Tonggasem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
It Work Week 10-11 not finish
parent
e4870870
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
202 additions
and
0 deletions
+202
-0
index.html
week10-11/crudwebapp/index.html
+124
-0
nodejs-60-2
week10-11/crudwebapp/nodejs-60-2
+1
-0
package-lock.json
week10-11/crudwebapp/package-lock.json
+0
-0
package.json
week10-11/crudwebapp/package.json
+29
-0
server.js
week10-11/crudwebapp/server.js
+48
-0
No files found.
week10-11/crudwebapp/index.html
0 → 100644
View file @
8deb2831
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"msapplication-tap-highlight"
content=
"no"
>
<meta
name=
"description"
content=
"Materialize is a Material Design Admin Template,It's modern, responsive and based on Material Design by Google. "
>
<meta
name=
"keywords"
content=
"materialize, admin template, dashboard template, flat admin template, responsive admin template,"
>
<title>
Login Page | Materialize - Material Design Admin Template
</title>
<!-- Favicons-->
<link
rel=
"icon"
href=
"images/favicon/favicon-32x32.png"
sizes=
"32x32"
>
<!-- Favicons-->
<link
rel=
"apple-touch-icon-precomposed"
href=
"images/favicon/apple-touch-icon-152x152.png"
>
<!-- For iPhone -->
<meta
name=
"msapplication-TileColor"
content=
"#00bcd4"
>
<meta
name=
"msapplication-TileImage"
content=
"images/favicon/mstile-144x144.png"
>
<!-- For Windows Phone -->
<!-- CORE CSS-->
<link
href=
"css/materialize.min.css"
type=
"text/css"
rel=
"stylesheet"
media=
"screen,projection"
>
<link
href=
"css/style.min.css"
type=
"text/css"
rel=
"stylesheet"
media=
"screen,projection"
>
<!-- Custome CSS-->
<link
href=
"http://demo.geekslabs.com/materialize-v1.0/css/custom/custom.min.css"
type=
"text/css"
rel=
"stylesheet"
media=
"screen,projection"
>
<link
href=
"http://demo.geekslabs.com/materialize-v1.0/css/layouts/page-center.css"
type=
"text/css"
rel=
"stylesheet"
media=
"screen,projection"
>
<!-- Compiled and minified CSS -->
<link
rel=
"stylesheet"
href=
"https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css"
>
<!-- Compiled and minified JavaScript -->
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/js/materialize.min.js"
></script>
<!-- INCLUDED PLUGIN CSS ON THIS PAGE -->
<link
href=
"http://demo.geekslabs.com/materialize-v1.0/js/plugins/prism/prism.css"
type=
"text/css"
rel=
"stylesheet"
media=
"screen,projection"
>
<link
href=
"http://demo.geekslabs.com/materialize-v1.0/js/plugins/perfect-scrollbar/perfect-scrollbar.css"
type=
"text/css"
rel=
"stylesheet"
media=
"screen,projection"
>
</head>
<body
class=
"cyan"
>
<!-- Start Page Loading -->
<div
id=
"loader-wrapper"
>
<div
id=
"loader"
></div>
<div
class=
"loader-section section-left"
></div>
<div
class=
"loader-section section-right"
></div>
</div>
<!-- End Page Loading -->
<div
id=
"login-page"
class=
"row"
>
<div
class=
"col s12 z-depth-4 card-panel"
>
<form
class=
"login-form"
action=
"/quotes"
method=
"POST"
>
<div
class=
"row"
>
<div
class=
"input-field col s12 center"
>
<img
src=
"http://demo.geekslabs.com/materialize-v1.0/images/login-logo.png"
alt=
""
class=
"circle responsive-img valign profile-image-login"
>
<p
class=
"center login-form-text"
>
Material Design Admin Template
</p>
</div>
</div>
<div
class=
"row margin"
>
<div
class=
"input-field col s12"
>
<i
class=
"mdi-social-person-outline prefix"
></i>
<input
id=
"name"
type=
"text"
name=
"name"
>
<label
for=
"name"
class=
"center-align"
>
Name
</label>
</div>
</div>
<div
class=
"row margin"
>
<div
class=
"input-field col s12"
>
<i
class=
"mdi-action-lock-outline prefix"
></i>
<input
id=
"quote"
type=
"text"
name=
"quote"
>
<label
for=
"quote"
>
Quote
</label>
</div>
</div>
<div
class=
"row"
>
<div
class=
"input-field col s12 m12 l12 login-text"
>
<input
type=
"checkbox"
id=
"remember-me"
/>
<label
for=
"remember-me"
>
Remember me
</label>
</div>
</div>
<div
class=
"row"
>
<div
class=
"input-field col s12"
>
<button
type=
"submit"
class=
"btn waves-effect waves-light col s12"
>
Login
</a>
</div>
</div>
<div
class=
"row"
>
<div
class=
"input-field col s6 m6 l6"
>
<p
class=
"margin medium-small"
><a
href=
"page-register.html"
>
Register Now!
</a></p>
</div>
<div
class=
"input-field col s6 m6 l6"
>
<p
class=
"margin right-align medium-small"
><a
href=
"page-forgot-password.html"
>
Forgot password ?
</a></p>
</div>
</div>
</form>
</div>
</div>
<!-- ================================================
Scripts
================================================ -->
<!-- jQuery Library -->
<script
type=
"text/javascript"
src=
"js/plugins/jquery-1.11.2.min.js"
></script>
<!--materialize js-->
<script
type=
"text/javascript"
src=
"js/materialize.min.js"
></script>
<!--prism-->
<script
type=
"text/javascript"
src=
"js/plugins/prism/prism.js"
></script>
<!--scrollbar-->
<script
type=
"text/javascript"
src=
"js/plugins/perfect-scrollbar/perfect-scrollbar.min.js"
></script>
<!--plugins.js - Some Specific JS codes for Plugin Settings-->
<script
type=
"text/javascript"
src=
"js/plugins.min.js"
></script>
<!--custom-script.js - Add your own theme custom JS-->
<script
type=
"text/javascript"
src=
"js/custom-script.js"
></script>
</body>
</html>
\ No newline at end of file
nodejs-60-2
@
89d3eac4
Subproject commit 89d3eac456e88c2a64714bea6381b6121d53f2dd
week10-11/crudwebapp/package-lock.json
0 → 100644
View file @
8deb2831
This diff is collapsed.
Click to expand it.
week10-11/crudwebapp/package.json
0 → 100644
View file @
8deb2831
{
"name"
:
"crudwebapp"
,
"version"
:
"0.1.0"
,
"description"
:
"crud application to mongodb throught expressjs"
,
"main"
:
"sever.js"
,
"scripts"
:
{
"start"
:
"nodemon server.js"
,
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"repository"
:
{
"type"
:
"git"
,
"url"
:
"http://projectcs.sci.ubu.ac.th/Tlex/nodejs-60-2.git"
},
"keywords"
:
[
"CRUD"
,
"mongodb"
,
"expressjs"
,
"ubu"
,
"comsci"
],
"author"
:
"Tlex"
,
"license"
:
"ISC"
,
"dependencies"
:
{
"body-parser"
:
"^1.18.2"
,
"express"
:
"^4.16.3"
,
"mongodb"
:
"^3.0.5"
,
"save"
:
"^2.3.2"
}
}
week10-11/crudwebapp/server.js
0 → 100644
View file @
8deb2831
const
express
=
require
(
'express'
);
const
parser
=
require
(
'body-parser'
);
const
app
=
express
();
/*
app.get('/', (req, res) => {
res.send('ทำงานอยู่นะครับ... it works!!!');
});
*/
const
mongodb
=
require
(
'mongodb'
)
const
client
=
mongodb
.
MongoClient
;
var
url
=
"mongodb://localhost:27017/crudwebappdb"
;
app
.
use
(
parser
.
urlencoded
({
extended
:
true
}))
app
.
get
(
'/test'
,
(
req
,
res
)
=>
{
res
.
send
(
'Test Test'
);
});
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
res
.
sendFile
(
__dirname
+
'/index.html'
);
});
app
.
post
(
'/quotes'
,
(
req
,
res
)
=>
{
console
.
log
(
req
.
body
);
});
app
.
listen
(
8000
,
function
()
{
console
.
log
(
"เริ่มละนะ "
);
client
.
connect
(
url
,
(
err
,
con
)
=>
{
if
(
err
)
throw
err
;
console
.
log
(
"Database ชื่อ crudwebappdb สร้างแล้วเด้อ!"
);
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
console
.
log
(
db
.
collection
(
'quotes'
).
find
());
res
.
sendFile
(
__dirname
+
'/index.html'
);
});
let
db
=
con
.
db
(
'crudwebappdb'
);
app
.
post
(
'/quotes'
,
(
req
,
res
)
=>
{
console
.
log
(
req
.
body
);
db
.
collection
(
'quotes'
).
insertOne
(
req
.
body
,
(
err
,
result
)
=>
{
if
(
err
)
return
console
.
log
(
err
)
console
.
log
(
`บันทึก
${
req
.
body
}
ไปที่ database แล้ว`
)
res
.
redirect
(
'/'
)
})
});
app
.
listen
(
8000
,
function
()
{
console
.
log
(
"เริ่มละนะ "
);
});
//con.close();
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment