Last active
March 26, 2019 13:40
-
-
Save ivanleoncz/92b78ff8c9a6a4fed4e7019e1b132a0e to your computer and use it in GitHub Desktop.
Simple Express.js Application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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