index.js
947 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
42
43
44
45
46
47
48
49
50
51
var express = require('express')
var app = express()
var mysql = require('mysql')
var router = express.Router();
var path = require('path')
var passport = require('passport')
var LocalStrategy = require('passport-local').Strategy;
var connection = mysql.createConnection({
host: 'localhost',
port: 3306,
user: 'root',
password: 'ksmhjh88',
database: 'nodetest'
})
connection.connect()
router.get('/list', function (req, res) {
res.render('customer.ejs');
})
// 1. /market , get
router.get('/',function(req,res){
var responseData = {};
var query = connection.query('select * from market', function(err, rows) {
if(err) throw err;
if(rows.length) {
console.log(rows)
responseData.result = 1;
responseData.data = rows;
} else {
responseData.result = 0;
}
res.json(responseData)
})
})
module.exports = router;