Compare commits
No commits in common. "eb6da8aa1b95b0f84df665f9096f03031c194050" and "b649e86a43aab977802f6d520444e543536b2081" have entirely different histories.
eb6da8aa1b
...
b649e86a43
@ -1,49 +1,14 @@
|
|||||||
/*const router = require('express').Router();
|
|
||||||
|
|
||||||
module.exports = router;
|
|
||||||
|
|
||||||
router.get('/teachers', (request, response) => {
|
|
||||||
response.send(require('../json/teachers/success.json'))
|
|
||||||
})
|
|
||||||
|
|
||||||
router.get('/account', (request, response) => {
|
|
||||||
response.send(require('../json/account/account.json'))
|
|
||||||
})
|
|
||||||
|
|
||||||
router.post('/login', (request, response) => {
|
|
||||||
response.send(require('../json/login/success.json'))
|
|
||||||
})*/
|
|
||||||
const router = require('express').Router();
|
const router = require('express').Router();
|
||||||
|
|
||||||
router.get('/teachers', (request, response) => {
|
router.get('/teachers', (request, response) => {
|
||||||
response.send(require('../json/teachers/success.json'))
|
response.send(require('./json/teachers/success.json'))
|
||||||
})
|
})
|
||||||
|
|
||||||
router.get('/account', (request, response) => {
|
router.get('/account', (request, response) => {
|
||||||
response.send(require('../json/account/account.json'))
|
response.send(require('./json/account/account.json'))
|
||||||
})
|
})
|
||||||
|
|
||||||
router.post('/login', (request, response) => {
|
router.post('/login', (request, response) => {
|
||||||
const login = request.body.login;
|
response.send(require('./json/login/success.json'))
|
||||||
const password = request.body.password;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const users = require('../json/account/account.json');
|
|
||||||
const user = users.data.find(user => user.login === login && user.password === password);
|
|
||||||
|
|
||||||
if (!user) {
|
|
||||||
return response.status(401).send('Неверные данные');
|
|
||||||
}
|
|
||||||
|
|
||||||
const responseObject = {
|
|
||||||
login: user.login,
|
|
||||||
}
|
|
||||||
return response.json(responseObject);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error reading file:', error);
|
|
||||||
response.status(400).send('Internal server error');
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
module.exports = router;
|
|
@ -1,28 +1,26 @@
|
|||||||
{
|
{
|
||||||
"data": [
|
"data": [
|
||||||
{
|
{
|
||||||
"login": "user1",
|
"login": "user1",
|
||||||
"password":"1234",
|
"photo": "boy",
|
||||||
"photo": "boy",
|
"surname": "Иванов",
|
||||||
"surname": "Иванов",
|
"name": "Иван",
|
||||||
"name": "Иван",
|
"class": "2",
|
||||||
"class": "2",
|
"group": "1",
|
||||||
"group": "1",
|
"number": "+7 927 030 13 00",
|
||||||
"number": "+7 927 030 13 00",
|
"teacher": "Иванова Валерия Константиновна",
|
||||||
"teacher": "Иванова Валерия Константиновна",
|
"lessons": ["02.05", "07.05", "14.05", "17.05", "21.05", "24.05", "28.05"]
|
||||||
"lessons": ["02.05", "07.05", "14.05", "17.05", "21.05", "24.05", "28.05"]
|
},
|
||||||
},
|
{
|
||||||
{
|
"login": "user2",
|
||||||
"login": "user2",
|
"photo": "boy",
|
||||||
"password":"123",
|
"surname": "Александров",
|
||||||
"photo": "boy",
|
"name": "Александр",
|
||||||
"surname": "Иванов",
|
"class": "3",
|
||||||
"name": "Иван",
|
"group": "2",
|
||||||
"class": "2",
|
"number": "+7 927 030 13 00",
|
||||||
"group": "1",
|
"teacher": "Иванова Валерия Константиновна",
|
||||||
"number": "+7 927 030 13 00",
|
"lessons": ["02.05", "07.05", "14.05", "17.05", "21.05", "24.05", "28.05"]
|
||||||
"teacher": "Иванова Валерия Константиновна",
|
}
|
||||||
"lessons": ["02.05", "07.05", "14.05", "17.05", "21.05", "24.05", "28.05"]
|
]
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user