Skapar en container med dockerfil och allt
This commit is contained in:
12
server.js
12
server.js
@@ -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.');
|
||||
|
||||
Reference in New Issue
Block a user