Thursday, 27 April 2017

How to implement download file from heroku server in nodejs

I have a nodejs application where I have created project structure. package.json and index.js files, one json file also which I want that user can download it.

This is how my project structure

enter image description here

I have deployed nodejs application on heroku server. It is running perfectly, able to access index.js

How I can implement a functionality here so users can download swagger.json also. I tried to access this like https://heroku-address/swagger.json but it is showing only "Hello World"

index.js

var http = require("http");

http.createServer(function (request, response) {

   // Send the HTTP header 
   // HTTP Status: 200 : OK
   // Content Type: text/plain
   response.writeHead(200, {'Content-Type': 'text/plain'});

   // Send the response body as "Hello World"
   response.end('Hello World\n');
}).listen(process.env.PORT);



via Williams

No comments:

Post a Comment