Advertisement
jci

fflores

jci
Sep 25th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. var http = require('http');
  2. http.createServer(function (req, res) {
  3. const { headers, method, url } = req;
  4.  
  5. var Pool = require('pg').Pool;
  6. var config = {
  7. host: 'localhost',
  8. user: 'postgres',
  9. password: 'sandermaster',
  10. database: 'billboard',
  11. };
  12.  
  13. var pool = new Pool(config);
  14. var numrows = 0;
  15.  
  16. async function get_hits(){
  17. var response = await pool.query("SELECT * FROM hot100" );
  18. numrows = response.rows;
  19. console.log(response.rows);
  20. }
  21.  
  22. get_hits();
  23. res.writeHead(200, {'Content-Type': 'text/plain'});
  24. res.write(numrows);
  25. res.end();
  26. }).listen(8080, '192.168.0.10');
  27. console.log('Server running at http://192.168.0.10:8080/');
  28.  
  29. //o algo similar :B
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement