From b5c3c046f17eb28555f9398bcbc741ae8240676b Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Mon, 19 Aug 2024 17:58:55 +0800 Subject: chore: update content --- .github/workflows/Deploy_Nodejs.yml | 31 ++++++++++++++++++++++ .gitignore | 2 ++ Pipefile | 10 ------- index.html | 15 ----------- index.js | 30 +++++++++++++++++++++ package.json | 11 ++++++++ public/index.html | 53 +++++++++++++++++++++++++++++++++++++ requirements.txt | 1 - yarn.lock | 4 +++ 9 files changed, 131 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/Deploy_Nodejs.yml delete mode 100644 Pipefile delete mode 100644 index.html create mode 100644 index.js create mode 100644 package.json create mode 100644 public/index.html delete mode 100644 requirements.txt create mode 100644 yarn.lock diff --git a/.github/workflows/Deploy_Nodejs.yml b/.github/workflows/Deploy_Nodejs.yml new file mode 100644 index 0000000..80d3b2e --- /dev/null +++ b/.github/workflows/Deploy_Nodejs.yml @@ -0,0 +1,31 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Install dependencies + run: yarn install + + - name: Build project + run: yarn build + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./public \ No newline at end of file diff --git a/.gitignore b/.gitignore index 68bc17f..e1361d9 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,5 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +node_modules/ \ No newline at end of file diff --git a/Pipefile b/Pipefile deleted file mode 100644 index 5ece07a..0000000 --- a/Pipefile +++ /dev/null @@ -1,10 +0,0 @@ -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] -flask = "*" - -[requires] -python_version = "3.9" \ No newline at end of file diff --git a/index.html b/index.html deleted file mode 100644 index 089bf42..0000000 --- a/index.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - Files - - -

Files

- - - \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..51c542b --- /dev/null +++ b/index.js @@ -0,0 +1,30 @@ +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 diff --git a/package.json b/package.json new file mode 100644 index 0000000..0e815cf --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "files", + "version": "1.0.0", + "author": {"name": "简律纯"}, + "scripts": { + "build": "echo 'No build step required'" + }, + "dependencies": { + "express": "^4.17.1" + } + } \ No newline at end of file diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..a232c7c --- /dev/null +++ b/public/index.html @@ -0,0 +1,53 @@ + + + + + + Directory Tree + + + +

Files Directory Tree

+
+ + + + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 2077213..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -Flask \ No newline at end of file diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + -- cgit v1.2.3-70-g09d2