Skip to content

Instantly share code, notes, and snippets.

@ZaninAndrea
Created November 1, 2017 15:37
Show Gist options
  • Save ZaninAndrea/de5dcfe986dac998c736b2eb38087594 to your computer and use it in GitHub Desktop.
Save ZaninAndrea/de5dcfe986dac998c736b2eb38087594 to your computer and use it in GitHub Desktop.
server
// init project
const express = require('express'); // the library we will use to handle requests
const app = express(); // instantiate express
app.use(require("cors")()) // allow Cross-domain requests
// base route
app.get("/", function (request, response) {
response.send("TODO") // always responds with the string "TODO"
});
// base route
app.post("/", function (request, response) {
response.send("TODO") // always responds with the string "TODO"
});
app.put("/", function (request, response) {
response.send("TODO") // always responds with the string "TODO"
});
// listen for requests, the process.env.PORT is needed because
// we are using glitch, otherwise you could have written 80 or whatever
var listener = app.listen(process.env.PORT, function () {
console.log('Your app is listening on port ' + listener.address().port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment