- Download all files from the gist to the target folder, from where you want to make all files make avaiable for download
- Install the 'express' & 'ejs'
- start the server.js with node
- visit link: http://localhost:3000/
Last active
January 3, 2021 08:56
-
-
Save kamal-hossain/9ecc5e3ce30e4e17e989e98f11bd7402 to your computer and use it in GitHub Desktop.
Download these in the directory from where you want to download all files. Install express & ejs.
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Simple File download template</title> | |
</head> | |
<body> | |
<h1 style="text-decoration: line-through;"> | |
Click to Download all. <button class="all-download">Download</button> | |
</h1> | |
<% files.forEach(function(post) { %> | |
<h4><%= post %> <a href="./<%= post %>" download>Download</a></h4> | |
<% }) %> | |
<script> | |
// document.querySelector('.all-download').addEventListener('click', e => { | |
// console.log(files); | |
// console.log('Downloading'); | |
// }); | |
</script> | |
</body> | |
</html> |
This file contains 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
{ | |
"name": "kamal", | |
"version": "1.0.0", | |
"description": "", | |
"main": "server.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "node server.js" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"ejs": "^3.0.1", | |
"express": "^4.17.1" | |
} | |
} |
This file contains 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
// install express and ejs for using this as folder server | |
// copy all files in the target directory that needs to be downloaded and start the server with node | |
const express = require('express'); | |
const app = express(); | |
var fs = require('fs'); | |
var files = fs.readdirSync('./'); | |
app.use(express.static(__dirname + '/')); // making the root folder public to connect css/js files | |
app.set('view engine', 'ejs'); // set the view engine to ejs | |
app.set('views', './'); // set the folder to lookup files for ejs | |
app.get('/', (req, res) => { | |
// console.log(files); | |
res.render('index', { files: files }); | |
}); | |
app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment