Advertisement
yacht_rock_tom

fuckedDogApp

Aug 17th, 2019
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Another way to do some of this: var express = require('express')   var app = express()
  2.  
  3. // http.createServer(function (req,res) {
  4. //     res.writeHead(200, {'Content-type':'image/png'});
  5. //     request('https://random.dog/86a6af7a-eee8-4c04-8730-8656593f34d9.gif', function (error, response, body) {
  6. //         req.get('https://random.dog/86a6af7a-eee8-4c04-8730-8656593f34d9.gif',error)
  7. //             if(error) {
  8. //                 console.log('Something went wrong!');
  9. //             }else{
  10. //                 console.log('Got the image!!');
  11. //                 res.end(response.body);
  12. //             }
  13. //
  14. //         });
  15. //         console.log('error:', error); // Print the error if one occurred
  16. //         console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
  17. //         console.log('body:', body); // Print the HTML for the dog homepage.
  18. //         res.send(body);
  19. //         res.end('Done!');
  20. //     });
  21. //
  22. // }).listen(port);
  23.  
  24.  
  25. // //create http server listening on port 8080
  26. // http.createServer(function (req, res) {
  27. //     //use the url to parse the requested url and get the image name
  28. //     var query = url.parse(req.url,true).query;
  29. //     pic = query.image;
  30. //
  31. //     //read the image using fs and send the image content back in the response
  32. //     fs.readFile('/my-image' + pic, function (err, content) {
  33. //         if (err) {
  34. //             res.writeHead(400, {'Content-type':'text/html'})
  35. //             console.log(err);
  36. //             res.end("No such image");
  37. //         } else {
  38. //             //specify the content type in the response will be an image
  39. //             res.writeHead(200,{'Content-type':'image/jpg'});
  40. //             res.end(content);
  41. //         }
  42. //     });
  43. // }).listen(8080);
  44. // console.log("Server running at http://localhost:8080/");
  45.  
  46. const http = require('http');
  47. const url = require('url');
  48. const port = 8080;
  49. const request = require('request');
  50. const axios = require('axios');
  51.  
  52. var bodyParser = require("body-parser");
  53. var express = require('express');
  54. const fs = require('fs');
  55. const app = express();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement