Last active
March 22, 2019 18:58
-
-
Save clarkhacks/5e761bf8e7da4ca0d1d6d0029e9f8c0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var serveIndex = require('serve-index'); | |
var app = express(); | |
app.use('/public', serveIndex('files')); // shows you the file list | |
app.use('/public', express.static('files')); // serve the actual files | |
app.get("/clear", function(req, res) { | |
const fs = require('fs'); | |
const path = require('path'); | |
const directory = '/motion'; | |
fs.readdir(directory, (err, files) => { | |
if (err) throw err; | |
for (const file of files) { | |
fs.unlink(path.join(directory, file), err => { | |
if (err) throw err; | |
}); | |
} | |
}); | |
}); | |
app.listen(8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment