Commit 929179ee authored by Patiphan Marak's avatar Patiphan Marak

week11

parent 78770122
{
"lockfileVersion": 1
}
<!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</button>
</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>
This diff is collapsed.
{
"name": "crudwebapp",
"version": "0.1.0",
"description": "crud application to mongodb through expressjs",
"main": "server.js",
"scripts": {
"start": "nodemon server.js",
"test": "echo \"Error: no test specified\" && exit 1",
"mongodbpath": "mongod --dbpath ~/.mongodb/crudwebapp/"
},
"repository": {
"type": "git",
"url": "http://projectcs.sci.ubu.ac.th/paul/nodejs-60-2"
},
"keywords": [
"CRUD",
"mongodb",
"expressjs",
"ubu",
"comsci"
],
"author": "wichit.sombat",
"license": "ISC",
"dependencies": {
"body-parser": "^1.18.2",
"express": "^4.16.3",
"mongodb": "^3.0.5"
}
}
const express = require('express');
const parser = require('body-parser');
const app = express();
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');
});
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();
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment