Skip to content

Instantly share code, notes, and snippets.

@dceddia dceddia/server.js
Created Jun 15, 2018

What would you like to do?
Handle GET requests
// View latest image
app.get('/', (req, res) => {
// Does this session have an image yet?
if(!latestPhoto) {
return res.status(404).send("Nothing here yet");
console.log('sending photo');
try {
// Send the image
var img = Buffer.from(latestPhoto, 'base64');
res.writeHead(200, {
'Content-Type': 'image/png',
'Content-Length': img.length
} catch(e) {
// Log the error and stay alive
return res.sendStatus(500);
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.