Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Another way to do some of this: var express = require('express') var app = express()
- // http.createServer(function (req,res) {
- // res.writeHead(200, {'Content-type':'image/png'});
- // request('https://random.dog/86a6af7a-eee8-4c04-8730-8656593f34d9.gif', function (error, response, body) {
- // req.get('https://random.dog/86a6af7a-eee8-4c04-8730-8656593f34d9.gif',error)
- // if(error) {
- // console.log('Something went wrong!');
- // }else{
- // console.log('Got the image!!');
- // res.end(response.body);
- // }
- //
- // });
- // console.log('error:', error); // Print the error if one occurred
- // console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
- // console.log('body:', body); // Print the HTML for the dog homepage.
- // res.send(body);
- // res.end('Done!');
- // });
- //
- // }).listen(port);
- // //create http server listening on port 8080
- // http.createServer(function (req, res) {
- // //use the url to parse the requested url and get the image name
- // var query = url.parse(req.url,true).query;
- // pic = query.image;
- //
- // //read the image using fs and send the image content back in the response
- // fs.readFile('/my-image' + pic, function (err, content) {
- // if (err) {
- // res.writeHead(400, {'Content-type':'text/html'})
- // console.log(err);
- // res.end("No such image");
- // } else {
- // //specify the content type in the response will be an image
- // res.writeHead(200,{'Content-type':'image/jpg'});
- // res.end(content);
- // }
- // });
- // }).listen(8080);
- // console.log("Server running at http://localhost:8080/");
- const http = require('http');
- const url = require('url');
- const port = 8080;
- const request = require('request');
- const axios = require('axios');
- var bodyParser = require("body-parser");
- var express = require('express');
- const fs = require('fs');
- const app = express();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement