Skapar en container med dockerfil och allt

This commit is contained in:
2025-01-23 20:54:35 +01:00
parent 6eff6e7e77
commit 2e160f8314
4 changed files with 49 additions and 3 deletions

View File

@@ -9,6 +9,12 @@ const port = 3044;
app.use(bodyParser.json());
app.use(express.static('public'));
// Ensure the /data directory exists
const dataDir = path.join('/data');
if (!fs.existsSync(dataDir)) {
fs.mkdirSync(dataDir, { recursive: true });
}
// Endpoint to receive task data and append to file
app.post('/add-task', (req, res) => {
const { subject, description, scheduled } = req.body;
@@ -18,7 +24,7 @@ app.post('/add-task', (req, res) => {
* TODO ${subject}
SCHEDULED: <${scheduled}>
:LOGBOOK:
- State "TODO" from [${currentDateTime}]
- State "TODO" from "TODO" [${currentDateTime}]
:END:
`;
@@ -28,12 +34,12 @@ app.post('/add-task', (req, res) => {
${description}
SCHEDULED: <${scheduled}>
:LOGBOOK:
- State "TODO" from [${currentDateTime}]
- State "TODO" from "TODO" [${currentDateTime}]
:END:
`;
}
const filePath = path.join(__dirname, 'tasks.org');
const filePath = path.join(dataDir, 'tasks.org');
fs.appendFile(filePath, orgFormattedData, (err) => {
if (err) {
return res.status(500).send('Error writing to file.');