Skip to content

Instantly share code, notes, and snippets.

@ivanleoncz
Last active March 26, 2019 13:40
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 ivanleoncz/92b78ff8c9a6a4fed4e7019e1b132a0e to your computer and use it in GitHub Desktop.
Save ivanleoncz/92b78ff8c9a6a4fed4e7019e1b132a0e to your computer and use it in GitHub Desktop.
Simple Express.js Application
var express = require('express');
var port = 3000;
var app = express();
app.get('/', function(req, res) {
res.send('<h1>Welcome! </h1>');
});
app.get('/username/:user_name', function(req, res) {
res.status(200);
res.set('Content-type', 'text/html');
res.send('<h1>Hello, ' + req.params.user_name + '!</h1>');
});
app.listen(port, function() {
console.log("Server is running: http://localhost:%s", port);
});
{
"name": "simple_ws",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"dependencies": {
"express": "^4.16.4"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment