Skip to content

Instantly share code, notes, and snippets.

@zprima
Created January 27, 2019 11:20
Show Gist options
  • Save zprima/ffd6c13d3e2a2172189da741a69d9c87 to your computer and use it in GitHub Desktop.
Save zprima/ffd6c13d3e2a2172189da741a69d9c87 to your computer and use it in GitHub Desktop.
medium_p1_c1
const express = require("express");
const bodyParser = require("body-parser");
const app = express();
const port = 3001;
// Middleware
// JSON parser middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.get("/api/ping", (req, res) => {
// random endpoint so that the client can call something
res.json({ "msg": "pong" })
});
// start the Express server
app.listen(port, () => {
console.log(`server started at http://localhost:${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment