Skip to content

Instantly share code, notes, and snippets.

@dceddia
Created June 15, 2018 02:03
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 dceddia/17fe2752532c95886b8d0f79258462fa to your computer and use it in GitHub Desktop.
Save dceddia/17fe2752532c95886b8d0f79258462fa to your computer and use it in GitHub Desktop.
Handle POST requests
// Store the single image in memory.
let latestPhoto = null;
// Upload the latest photo for this session
app.post('/', (req, res) => {
// Very light error handling
if(!req.body) return res.sendStatus(400);
console.log('got photo')
// Update the image and respond happily
latestPhoto = req.body.photo;
res.sendStatus(200);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment