improved main and fitness layout
This commit is contained in:
29
docs/personal-documentation/sebas/test.txt
Normal file
29
docs/personal-documentation/sebas/test.txt
Normal 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}`);
|
||||
});
|
Reference in New Issue
Block a user