fix: refactor networking scripts for improved robustness and clarity
This commit is contained in:
@ -9,6 +9,8 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const multer = require('multer');
|
||||
|
||||
const scriptsDir = path.join(__dirname, '../scripts');
|
||||
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
app.use(express.static(path.join(__dirname, '../frontend/dist')));
|
||||
@ -120,14 +122,14 @@ app.post('/media/assign', (req, res) => {
|
||||
|
||||
// Networking API
|
||||
app.post('/network/ap', (req, res) => {
|
||||
exec('bash scripts/switch-to-ap.sh', (err, stdout) => {
|
||||
exec(`bash "${path.join(scriptsDir, 'switch-to-ap.sh')}"`, (err, stdout) => {
|
||||
if (err) return res.status(500).json({ error: err.message });
|
||||
res.json({ status: 'switching to ap', output: stdout });
|
||||
});
|
||||
});
|
||||
|
||||
app.post('/network/client', (req, res) => {
|
||||
exec('bash scripts/switch-to-client.sh', (err, stdout) => {
|
||||
exec(`bash "${path.join(scriptsDir, 'switch-to-client.sh')}"`, (err, stdout) => {
|
||||
if (err) return res.status(500).json({ error: err.message });
|
||||
res.json({ status: 'switching to client', output: stdout });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user