Showing
1 changed file
with
22 additions
and
0 deletions
| ... | @@ -6,13 +6,31 @@ const bodyParser = require('body-parser'); | ... | @@ -6,13 +6,31 @@ const bodyParser = require('body-parser'); |
| 6 | const axios = require('axios'); | 6 | const axios = require('axios'); |
| 7 | const cheerio = require('cheerio'); | 7 | const cheerio = require('cheerio'); |
| 8 | const url = require('url'); | 8 | const url = require('url'); |
| 9 | +const mysql = require('mysql'); | ||
| 10 | + | ||
| 9 | const router = express.Router(); | 11 | const router = express.Router(); |
| 10 | 12 | ||
| 13 | +const connection = mysql.createConnection({ | ||
| 14 | + host:'localhost', | ||
| 15 | + user:'root', | ||
| 16 | + password:'None', | ||
| 17 | + database:'maple' | ||
| 18 | +}); | ||
| 11 | 19 | ||
| 12 | const app = express(); | 20 | const app = express(); |
| 13 | 21 | ||
| 22 | +connection.connect(function(err){ | ||
| 23 | + if(!err) { | ||
| 24 | + console.log("Database is connected"); | ||
| 25 | + }else{ | ||
| 26 | + console.log("connecting error"); | ||
| 27 | + } | ||
| 28 | +}) | ||
| 29 | + | ||
| 14 | const server = http.createServer(app); | 30 | const server = http.createServer(app); |
| 15 | 31 | ||
| 32 | +app.set('views', __dirname + '/views'); | ||
| 33 | +app.set('view engine', 'ejs'); | ||
| 16 | app.use('/css',express.static('./css')); | 34 | app.use('/css',express.static('./css')); |
| 17 | app.use('/img',express.static('./img')); | 35 | app.use('/img',express.static('./img')); |
| 18 | app.use(express.static(path.join(__dirname, 'Python Scripts'))); | 36 | app.use(express.static(path.join(__dirname, 'Python Scripts'))); |
| ... | @@ -42,3 +60,7 @@ app.use(function(req,res,next){ | ... | @@ -42,3 +60,7 @@ app.use(function(req,res,next){ |
| 42 | server.listen(3000,function(){ | 60 | server.listen(3000,function(){ |
| 43 | console.log('server on'); | 61 | console.log('server on'); |
| 44 | }); | 62 | }); |
| 63 | + | ||
| 64 | + | ||
| 65 | + | ||
| 66 | + | ... | ... |
-
Please register or login to post a comment