KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have my first node.js app (runs fine locally) - but I am unable to deploy it via heroku (first time w/ heroku as well). The code is below. SO doesn't let me write so much code, so I would just say that the running the code locally as well within my network shows no issue. var http = require('http'); var fs = require('fs'); var path = require('path'); http.createServer(function (request, response) { console.log('request starting for '); console.log(request); var filePath = '.' + request.url; if (filePath == './') filePath = './index.html'; console.log(filePath); var extname = path.extname(filePath); var contentType = 'text/html'; switch (extname) { case '.js': contentType = 'text/javascript'; break; case '.css': contentType = 'text/css'; break; } path.exists(filePath, function(exists) { if (exists) { fs.readFile(filePath, function(error, content) { if (error) { response.writeHead(500); response.end(); } else { response.writeHead(200, { 'Content-Type': contentType }); response.end(content, 'utf-8'); } }); } else { response.writeHead(404); response.end(); } }); }).listen(5000); console.log('Server running at http://127.0.0.1:5000/'); Any idea ?
Tags (comma-separated)
Save Edits
Cancel