-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
33 lines (27 loc) · 923 Bytes
/
server.js
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
///////////////////////////////// connect to mysql database
var mysql = require('mysql');
var db = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'FracturedL2}',
database: 'MySQL80'
})
db.connect((err) => {
if(err) throw err;
console.log('MySQL connected');
});
/////////////////////////////////
const express = require('express');
var request = require('request');
const app = express();
const port = 5000;
// creates a route
app.get("/api/getArtOutput", (req, res) => {
let sql = ''; // pass query into here. if possible, form this query in the front end?
let query = db.query(sql, (err, results) => { // grab onto results and pass it into the app
if(err) throw err;
console.log(results);
res.send('');
});
});
app.listen(port, () => console.log(`Server started on port ${port}`));