aboutsummaryrefslogtreecommitdiffstats
path: root/backend/main.js
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2023-04-13 23:19:23 +0200
committerMaksymilian Jopek <maks@jopek.eu>2023-04-13 23:19:23 +0200
commit1871b834a715be2e8c4e25938cf3db3866a80ec6 (patch)
treecb5eba8e41a1aa19d9d511567f901d73b89e0981 /backend/main.js
parent4582aee9c51800f7b236fc9d731829c16254429f (diff)
downloadaparatus-1871b834a715be2e8c4e25938cf3db3866a80ec6.tar.gz
aparatus-1871b834a715be2e8c4e25938cf3db3866a80ec6.tar.zst
aparatus-1871b834a715be2e8c4e25938cf3db3866a80ec6.zip
Add Readme and LicenseHEADmaster
Fix bug when without upload folder
Diffstat (limited to 'backend/main.js')
-rw-r--r--backend/main.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/backend/main.js b/backend/main.js
index ae330b1..2ec749f 100644
--- a/backend/main.js
+++ b/backend/main.js
@@ -1,6 +1,7 @@
const express = require("express");
const formidable = require('formidable');
const fs = require("fs").promises
+const fss = require("fs")
const app = express();
app.use(express.static('static'))
@@ -40,7 +41,10 @@ app.post('/rename-file', async (req, res) => {
app.get('/files', async (_, res) => {
res.json(await fs.readdir(__dirname + '/static/upload'))
});
+
+if (!fss.existsSync(uploadDir)){
+ fss.mkdirSync(uploadDir);
+}
app.listen(PORT, () => {
console.log("Server listening on port " + PORT);
})
-