improved main and fitness layout

This commit is contained in:
SebasKoedam
2024-05-23 18:09:43 +02:00
parent 9795ccb490
commit 25f9f098b0
9 changed files with 121 additions and 118 deletions

View File

@@ -0,0 +1,29 @@
const express = require('express');
const mariadb = require('mariadb');
const app = express();
const port = 3000;
const pool = mariadb.createPool({
host: 'localhost',
user: 'fitbot',
password: 'fitbot123',
database: 'fitbot',
connectionLimit: 5
});
app.get('/data', async (req, res) => {
let conn;
try {
conn = await pool.getConnection();
const rows = await conn.query('SELECT * FROM Exercise');
res.json(rows);
} catch (err) {
res.status(500).json({ error: err.message });
} finally {
if (conn) conn.release();
}
});
app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);
});