Skip to content

Instantly share code, notes, and snippets.

@maximgatilin
Created February 19, 2017 16:12
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 maximgatilin/7d03fc8863fce009cb45d5de64bc71a1 to your computer and use it in GitHub Desktop.
Save maximgatilin/7d03fc8863fce009cb45d5de64bc71a1 to your computer and use it in GitHub Desktop.
Basic Express params #tags:express
'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