Skip to content

Instantly share code, notes, and snippets.

Created February 21, 2017 22:39
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
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();
// while your program is running, requests to "/test" will trigger this
// callback function.
app.get("/test", function(req, res) {
// the "req" parameter is an object that gives you access to data in the
// request.
var message = req.query.message;
// the "res" parameter lets you manipulate the response.
// 4000 is the port. if you're running on your own computer, type
// http://localhost:4000/test?message=lowercase
// in the location bar. if you're on your digitalocean droplet
// (or whatever), go to
// http://SERVER-IP-ADDRESS/test?message=lowercase
// instead (replacing "SERVER-IP-ADDRESS" with your server's IP
// address or hostname.
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