Без опису

1234567891011121314151617181920212223242526272829303132333435
  1. var express = require('express');
  2. var app = express();
  3. var mysql = require('mysql');
  4. var bodyParser = require('body-parser');
  5. app.use(bodyParser.json({type:'application/json'}));
  6. app.use(bodyParser.urlencoded({extended:true}));
  7. var con = mysql.createConnectionI({
  8. host:'ada.uprrp.edu',
  9. user: 'pablo.puig1',
  10. password: '9NA3kSExI2fGE6eV',
  11. database: 'techos'
  12. });
  13. var server = app.listen(4545, function(){
  14. var host = server.address().address
  15. var host = server.address().port
  16. });
  17. con.connect(function(error){
  18. if(error) console.log(error);
  19. else console.log('connected');
  20. })
  21. app.get('/users', function(req, res){
  22. con.query('SELECT * FROM users', function(error, rows, fields){
  23. if(error) console.log(error)
  24. else{
  25. console.log(rows);
  26. }
  27. })
  28. })