aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/Deploy_Nodejs.yml31
-rw-r--r--.gitignore2
-rw-r--r--Pipefile10
-rw-r--r--index.html15
-rw-r--r--index.js30
-rw-r--r--package.json11
-rw-r--r--public/index.html53
-rw-r--r--requirements.txt1
-rw-r--r--yarn.lock4
9 files changed, 131 insertions, 26 deletions
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 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Files</title>
-</head>
-<body>
- <h1>Files</h1>
- <ul>
- <li><a href="images/">Images</a></li>
- <li><a href="videos/">Videos</a></li>
- <li><a href="documents/">Documents</a></li>
- <li><a href="text/">Text</a></li>
- </ul>
-</body>
-</html> \ 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 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Directory Tree</title>
+ <style>
+ ul {
+ list-style-type: none;
+ }
+ .directory {
+ font-weight: bold;
+ }
+ </style>
+</head>
+<body>
+ <h1>Files Directory Tree</h1>
+ <div id="directory-tree"></div>
+
+ <script>
+ async function fetchDirectoryTree() {
+ const response = await fetch('/api/files');
+ return response.json();
+ }
+
+ function createTreeElement(node) {
+ const li = document.createElement('li');
+ li.textContent = node.name;
+ if (node.isDirectory) {
+ li.classList.add('directory');
+ const ul = document.createElement('ul');
+ node.children.forEach(child => {
+ ul.appendChild(createTreeElement(child));
+ });
+ li.appendChild(ul);
+ }
+ return li;
+ }
+
+ async function displayDirectoryTree() {
+ const tree = await fetchDirectoryTree();
+ const treeContainer = document.getElementById('directory-tree');
+ const ul = document.createElement('ul');
+ tree.forEach(node => {
+ ul.appendChild(createTreeElement(node));
+ });
+ treeContainer.appendChild(ul);
+ }
+
+ displayDirectoryTree();
+ </script>
+</body>
+</html> \ 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
+
+