index.js
983 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
var express = require('express')
var app = express()
var mysql = require('mysql')
var router = express.Router();
var path = require('path')
var connection = mysql.createConnection({
host : 'localhost',
port : 3306,
user:'root',
password : 'ksmhjh88',
database : 'nodetest'
})
connection.connect()
router.post('/ajax',function(req,res) {
console.log("latitude :",req.body.latitude)
console.log("longitude :",req.body.longitude)
var latitude = req.body.latitude;
var longitude = req.body.longitude;
var title = req.body.title;
//var responseData = {'result' : 'ok' , 'email' : req.body.email};
//res.json(responseData)
//DB 처리
var responseData = {};
var sql = {title: title,latitude: latitude, longitude: longitude};
var query = connection.query('insert into market set ?' ,sql, function(err,rows) {
if(err) throw err
return res.json({'result' : 1});
})
})
module.exports = router;