-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomment.js
More file actions
41 lines (33 loc) · 928 Bytes
/
comment.js
File metadata and controls
41 lines (33 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Create web server
var express = require('express');
var app = express();
var port = 3000;
// Server start
app.listen(port, function(){
console.log('Server Start! port: ' + port);
});
// Set static file directory
app.use(express.static('public'));
// Set body-parser
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
// Set mysql
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '111111',
database : 'jsman'
});
connection.connect();
// Set router
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.engine('html', require('ejs').renderFile); // ejs template engine
// Set URL
app.get('/', function(req, res){
res.render('index.html');
});
app.post('/form', function(req, res){
res.render('email.ejs', {'email' : req.body.email});