From 45f878515881824618d032ff5e0032229a21239c Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Tue, 20 Aug 2024 21:36:26 +0800 Subject: chore: update content --- index.js | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 index.js (limited to 'index.js') diff --git a/index.js b/index.js deleted file mode 100644 index 51c542b..0000000 --- a/index.js +++ /dev/null @@ -1,30 +0,0 @@ -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('/api/files', (req, res) => { - const directoryPath = path.join(__dirname, 'files'); - const getDirectoryTree = (dirPath) => { - const files = fs.readdirSync(dirPath); - return files.map(file => { - const filePath = path.join(dirPath, file); - const isDirectory = fs.statSync(filePath).isDirectory(); - return { - name: file, - path: filePath, - isDirectory, - children: isDirectory ? getDirectoryTree(filePath) : [] - }; - }); - }; - res.json(getDirectoryTree(directoryPath)); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); \ No newline at end of file -- cgit v1.2.3-70-g09d2