Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simplest possible Express application
// simplest possible express app
var http = require('http');
var express = require('express');
var app = express();
// local database. When you restart the express server, the values will reset to original
let db = [
name: "Mike",
age: 23,
name: "Steven",
age: 26,
app.get("/person", function(req, res) {
// grab query parameters from request
const dbIndex = req.query.index;
// find that person in the database variable able
let person = db[dbIndex];
// return the person we are looking for
return res.json(person);
http.createServer(app).listen(4000, function() {
console.log("Express server listening on port 4000");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.