Skip to content

Instantly share code, notes, and snippets.

@MatteoRagni
Last active October 22, 2017 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatteoRagni/2be84fbece541e2f3f324b3cd8fd4b00 to your computer and use it in GitHub Desktop.
Save MatteoRagni/2be84fbece541e2f3f324b3cd8fd4b00 to your computer and use it in GitHub Desktop.
Simple app deployed on Heroku for this Stackoverflow question: https://stackoverflow.com/questions/46873665
<h1>Works</h1>
{
"name": "Enigma",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"keywords": [],
"author": "",
"license": "ISC"
}
web: node .
'use strict';
const http = require('http');
const fs = require('fs');
const server = http.createServer(function (request, response) {
console.log(request.method, request.url);
if (request.url == '/style.css'){
const css = fs.readFileSync('style.css', 'utf8');
response.end(css);
}else{
const html = fs.readFileSync('index.html', 'utf8');
response.end(html);
}
});
console.log('port = ', process.env.PORT);
server.listen(process.env.PORT || 3000);
console.log('Server Started, yay!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment