ZIP Downloader

Простой сервер для скачивания .zip файлов из директории
1 Скачайте Node.js

Если у вас нет Node.js, скачайте и установите его с официального сайта:

nodejs.org
💡 Совет: Скачайте LTS версию (стабильную). После установки проверьте в терминале: node -v и npm -v
2 Создайте папку проекта

Создайте папку для проекта, например zip-downloader, и перейдите в неё:

📁 zip-downloader/
  ├── 📄 server.js
  ├── 📄 package.json
  ├── 📁 public/
  │  └── 📄 index.html
  └── 📦 ваш-файл.zip
3 Создайте файлы

server.js — скопируйте код:

const express = require('express');
const fs = require('fs');
const path = require('path');
const app = express();
const PORT = 3000;

app.use(express.static('public'));

app.get('/scan-zip', (req, res) => {
    const files = fs.readdirSync('.');
    const zipFile = files.find(f => f.endsWith('.zip'));
    if (zipFile) {
        res.json({ found: true, filename: zipFile });
    } else {
        res.json({ found: false });
    }
});

app.get('/download/:filename', (req, res) => {
    const filename = req.params.filename;
    const filePath = path.join('.', filename);
    if (fs.existsSync(filePath) && filename.endsWith('.zip')) {
        res.download(filePath, filename);
    } else {
        res.status(404).send('File not found');
    }
});

app.listen(PORT, () => {
    console.log(`Server running on http://localhost:${PORT}`);
});

package.json — скопируйте:

{
  "name": "zip-downloader",
  "version": "1.0.0",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "express": "^4.18.2"
  }
}

public/index.html — скопируйте этот код:

(код будет вставлен автоматически)
4 Установите зависимости

Откройте терминал в папке проекта и выполните:

npm install

Это установит Express — фреймворк для сервера.

5 Положите .zip файл

Поместите любой .zip файл в корневую папку проекта (рядом с server.js).

📌 Важно: Файл должен иметь расширение .zip. Сервер найдет первый .zip файл в папке.
6 Запустите сервер

В терминале выполните:

npm start

Или:

node server.js

Вы увидите: Server running on http://localhost:3000

7 Откройте в браузере

Перейдите по адресу:

http://localhost:3000

Сайт автоматически найдет .zip файл и покажет кнопку для скачивания.

✅ Готово!

Теперь вы можете скачивать .zip файлы через красивый интерфейс

Скачать все файлы Скачать index.html
`; document.getElementById('htmlCode').textContent = htmlContent; function downloadHTML() { const blob = new Blob([htmlContent], { type: 'text/html' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'index.html'; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); } function downloadAll() { const files = [ { name: 'server.js', content: `const express = require('express'); const fs = require('fs'); const path = require('path'); const app = express(); const PORT = 3000; app.use(express.static('public')); app.get('/scan-zip', (req, res) => { const files = fs.readdirSync('.'); const zipFile = files.find(f => f.endsWith('.zip')); if (zipFile) { res.json({ found: true, filename: zipFile }); } else { res.json({ found: false }); } }); app.get('/download/:filename', (req, res) => { const filename = req.params.filename; const filePath = path.join('.', filename); if (fs.existsSync(filePath) && filename.endsWith('.zip')) { res.download(filePath, filename); } else { res.status(404).send('File not found'); } }); app.listen(PORT, () => { console.log(\`Server running on http://localhost:\${PORT}\`); });` }, { name: 'package.json', content: `{ "name": "zip-downloader", "version": "1.0.0", "main": "server.js", "scripts": { "start": "node server.js" }, "dependencies": { "express": "^4.18.2" } }` }, { name: 'public/index.html', content: htmlContent } ]; files.forEach((file, index) => { setTimeout(() => { const blob = new Blob([file.content], { type: 'text/plain' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = file.name; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); }, index * 300); }); } window.downloadHTML = downloadHTML; window.downloadAll = downloadAll;