Created
February 19, 2017 16:12
-
-
Save maximgatilin/7d03fc8863fce009cb45d5de64bc71a1 to your computer and use it in GitHub Desktop.
Basic Express params #tags:express
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
'use strict'; | |
var express = require('express'), | |
posts = require('./mock/posts.json'); | |
var app = express(); | |
app.get('/', function(req, res){ | |
res.send("<h1>I am with!</h1>"); | |
}); | |
debugger; | |
app.get('/blog/:title', function(req, res) { | |
var title = req.params.title; | |
var post = posts[title]; | |
res.send(post); | |
}); | |
app.listen(3000, function(){ | |
console.log("The frontend server is running on port 3000!") | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment