How do I insert a newline in Node.js when using Heroku? -
i'm trying create node.js application on heroku output 10 different ascii faces (i have module needed that). using node tutorial on heroku, i've set output 10 faces. however, when try run code, puts of faces inline each other. how should try make faces outputted (if that's word) on own lines?
my current index.js
follows:
var express = require('express'); var app = express(); var cool = require('cool-ascii-faces'); app.set('port', (process.env.port || 5000)); app.get('/', function(request, response) { var result = '' var times = process.env.times || 5 (i=0; < times; i++) result += cool(); response.send(result); }); app.listen(app.get('port'), function() { console.log("node app running on port: " + app.get('port')) })
i have .env
file set foreman use (when testing locally) contains following: times=9
if want have @ output, head on over here.
tl;dr: how use newlines in node?
i visited site in question , did view -> source. there's no markup of kind html, body, etc. assume browser interpret output html. ought work since we're using html tag , pair of pre tags indicate if see hard return ('\n') browser should display it.
app.get('/', function(request, response) { var result = '<html><pre>'; var times = process.env.times || 5 (i=0; < times; i++) result += cool() + '\n'; result += '</pre></html>'; response.send(result); });
Comments
Post a Comment