2021-08-30 18:54:57 +03:00
# Тестування працездатності системи
2024-05-21 21:40:46 +03:00
## Передумови
1. Налаштування віртуального середовища
```bash
python3 -m venv .
source bin/activate.fish
pip3 install flask mariadb
```
2021-08-30 18:54:57 +03:00
2024-05-21 21:40:46 +03:00
2. Запуск сервера:
```bash
flask --app server run
```
## Тестування компонентів
Система має два варіанти передачі індексів: у рядку шляху а б о в тілі запиту. Перевіримо, як працюють обидва варіанти.
### /api/survey
Цей шлях дозволяє використовувати всі 4 HTTP-методи, що використовуються в домовленості REST (GET, POST, PUT, DELETE).
Протестуємо кожен з них на практичному прикладі:
< pre style = "
color: #ffffff ;
font-size: 10pt;"
>
< span style = "filter: contrast(70%) brightness(190%);color:lime;" > user< / span > @debian-laptop < span style = "color:lime;" > ~/D/f/t/f/d/m/e/s/demo< / span > (master)> < span style = "color:#3333FF;" > curl< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -s< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > http://127.0.0.1:5000/api/survey< / span > < span style = "color:dimgray;" > < / span > < span style = "color:lime;" > |< / span > < span style = "color:dimgray;" > < / span > < span style = "color:#3333FF;" > jq< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > .< / span >
< span style = "font-weight:bold;" > [
{
< / span > < span style = "font-weight:bold;color:#3333FF;" > " id" < / span > < span style = "font-weight:bold;" > : < / span > 1< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isPaused" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isNamed" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " name" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " Test 1" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " duration" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " 1w" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " account_id" < / span > < span style = "font-weight:bold;" > : < / span > 10< span style = "font-weight:bold;" >
}< / span > < span style = "font-weight:bold;" > ,
{
< / span > < span style = "font-weight:bold;color:#3333FF;" > " id" < / span > < span style = "font-weight:bold;" > : < / span > 4< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isPaused" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isNamed" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " name" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " Test 2" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " duration" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " 1w" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " account_id" < / span > < span style = "font-weight:bold;" > : < / span > 5< span style = "font-weight:bold;" >
}< / span > < span style = "font-weight:bold;" >
]< / span >
< span style = "color:dimgray;" > < / span > < span style = "filter: contrast(70%) brightness(190%);color:lime;" > user< / span > @debian-laptop < span style = "color:lime;" > ~/D/f/t/f/d/m/e/s/demo< / span > (master)> < span style = "color:#3333FF;" > curl< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -X< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > POST< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -d< / span > < span style = "color:dimgray;" > < / span > < span style = "color:yellow;" > '{" isPaused" : false, " isNamed" : true, " name" : " Test 3" , " duration" : " 1w" , " account_id" : 2}'< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > --header< / span > < span style = "color:dimgray;" > < / span > < span style = "color:yellow;" > " Content-Type: application/json" < / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > http://127.0.0.1:5000/api/survey< / span >
{" success" : true}
< span style = "color:dimgray;" > < / span > < span style = "filter: contrast(70%) brightness(190%);color:lime;" > user< / span > @debian-laptop < span style = "color:lime;" > ~/D/f/t/f/d/m/e/s/demo< / span > (master)> < span style = "color:#3333FF;" > curl< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -s< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > http://127.0.0.1:5000/api/survey< / span > < span style = "color:dimgray;" > < / span > < span style = "color:lime;" > |< / span > < span style = "color:dimgray;" > < / span > < span style = "color:#3333FF;" > jq< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > .< / span >
< span style = "font-weight:bold;" > [
{
< / span > < span style = "font-weight:bold;color:#3333FF;" > " id" < / span > < span style = "font-weight:bold;" > : < / span > 1< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isPaused" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isNamed" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " name" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " Test 1" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " duration" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " 1w" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " account_id" < / span > < span style = "font-weight:bold;" > : < / span > 10< span style = "font-weight:bold;" >
}< / span > < span style = "font-weight:bold;" > ,
{
< / span > < span style = "font-weight:bold;color:#3333FF;" > " id" < / span > < span style = "font-weight:bold;" > : < / span > 4< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isPaused" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isNamed" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " name" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " Test 2" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " duration" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " 1w" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " account_id" < / span > < span style = "font-weight:bold;" > : < / span > 5< span style = "font-weight:bold;" >
}< / span > < span style = "font-weight:bold;" > ,
{
< / span > < span style = "font-weight:bold;color:#3333FF;" > " id" < / span > < span style = "font-weight:bold;" > : < / span > 12< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isPaused" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isNamed" < / span > < span style = "font-weight:bold;" > : < / span > 1< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " name" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " Test 3" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " duration" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " 1w" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " account_id" < / span > < span style = "font-weight:bold;" > : < / span > 2< span style = "font-weight:bold;" >
}< / span > < span style = "font-weight:bold;" >
]< / span >
< span style = "color:dimgray;" > < / span > < span style = "filter: contrast(70%) brightness(190%);color:lime;" > user< / span > @debian-laptop < span style = "color:lime;" > ~/D/f/t/f/d/m/e/s/demo< / span > (master)> < span style = "color:#3333FF;" > curl< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -X< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > PUT< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -d< / span > < span style = "color:dimgray;" > < / span > < span style = "color:yellow;" > '{" id" : 8, " isPaused" : true, " isNamed" : true, " name" : " Test 3" , " duration" : " 4w" , " account_id" : 2}'< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > --header< / span > < span style = "color:dimgray;" > < / span > < span style = "color:yellow;" > " Content-Type: application/json" < / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > http://127.0.0.1:5000/api/survey< / span >
{" success" : true}
< span style = "color:dimgray;" > < / span > < span style = "filter: contrast(70%) brightness(190%);color:lime;" > user< / span > @debian-laptop < span style = "color:lime;" > ~/D/f/t/f/d/m/e/s/demo< / span > (master)> < span style = "color:#3333FF;" > curl< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -s< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > http://127.0.0.1:5000/api/survey< / span > < span style = "color:dimgray;" > < / span > < span style = "color:lime;" > |< / span > < span style = "color:dimgray;" > < / span > < span style = "color:#3333FF;" > jq< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > .< / span >
< span style = "font-weight:bold;" > [
{
< / span > < span style = "font-weight:bold;color:#3333FF;" > " id" < / span > < span style = "font-weight:bold;" > : < / span > 1< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isPaused" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isNamed" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " name" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " Test 1" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " duration" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " 1w" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " account_id" < / span > < span style = "font-weight:bold;" > : < / span > 10< span style = "font-weight:bold;" >
}< / span > < span style = "font-weight:bold;" > ,
{
< / span > < span style = "font-weight:bold;color:#3333FF;" > " id" < / span > < span style = "font-weight:bold;" > : < / span > 4< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isPaused" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isNamed" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " name" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " Test 2" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " duration" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " 1w" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " account_id" < / span > < span style = "font-weight:bold;" > : < / span > 5< span style = "font-weight:bold;" >
}< / span > < span style = "font-weight:bold;" > ,
{
< / span > < span style = "font-weight:bold;color:#3333FF;" > " id" < / span > < span style = "font-weight:bold;" > : < / span > 12< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isPaused" < / span > < span style = "font-weight:bold;" > : < / span > 1< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isNamed" < / span > < span style = "font-weight:bold;" > : < / span > 1< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " name" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " Test 3" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " duration" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " 4w" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " account_id" < / span > < span style = "font-weight:bold;" > : < / span > 2< span style = "font-weight:bold;" >
}< / span > < span style = "font-weight:bold;" >
]< / span >
< span style = "color:dimgray;" > < / span > < span style = "filter: contrast(70%) brightness(190%);color:lime;" > user< / span > @debian-laptop < span style = "color:lime;" > ~/D/f/t/f/d/m/e/s/demo< / span > (master)> < span style = "color:#3333FF;" > curl< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -X< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > DELETE< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -d< / span > < span style = "color:dimgray;" > < / span > < span style = "color:yellow;" > '{" id" : 12}'< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > --header< / span > < span style = "color:dimgray;" > < / span > < span style = "color:yellow;" > " Content-Type: application/json" < / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > http://127.0.0.1:5000/api/survey< / span >
[{'id': 12, 'isPaused': 1, 'isNamed': 1, 'name': 'Test 3', 'duration': '4w', 'account_id': 2}]
< span style = "color:dimgray;" > < / span > < span style = "filter: contrast(70%) brightness(190%);color:lime;" > user< / span > @debian-laptop < span style = "color:lime;" > ~/D/f/t/f/d/m/e/s/demo< / span > (master)> < span style = "color:#3333FF;" > curl< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -s< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > http://127.0.0.1:5000/api/survey< / span > < span style = "color:dimgray;" > < / span > < span style = "color:lime;" > |< / span > < span style = "color:dimgray;" > < / span > < span style = "color:#3333FF;" > jq< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > .< / span >
< span style = "font-weight:bold;" > [
{
< / span > < span style = "font-weight:bold;color:#3333FF;" > " id" < / span > < span style = "font-weight:bold;" > : < / span > 1< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isPaused" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isNamed" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " name" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " Test 1" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " duration" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " 1w" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " account_id" < / span > < span style = "font-weight:bold;" > : < / span > 10< span style = "font-weight:bold;" >
}< / span > < span style = "font-weight:bold;" > ,
{
< / span > < span style = "font-weight:bold;color:#3333FF;" > " id" < / span > < span style = "font-weight:bold;" > : < / span > 4< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isPaused" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isNamed" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " name" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " Test 2" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " duration" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " 1w" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " account_id" < / span > < span style = "font-weight:bold;" > : < / span > 5< span style = "font-weight:bold;" >
}< / span > < span style = "font-weight:bold;" >
]< / span >
< / pre >
### /api/survey/\<id\>
У цьому випадку доступні лише 3 методи (GET, PUT, DELETE), оскільки під час створення нового опитування його ідентифікатор визначається безпосередньо базою даних.
< pre style = "
color: #ffffff ;
font-size: 10pt;"
>
< span style = "filter: contrast(70%) brightness(190%);color:lime;" > user< / span > @debian-laptop < span style = "color:lime;" > ~/D/f/t/f/d/m/e/s/restful-server< / span > (master)> < span style = "color:#3333FF;" > curl< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -s< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > http://127.0.0.1:5000/api/survey< / span > < span style = "color:dimgray;" > < / span > < span style = "color:lime;" > |< / span > < span style = "color:dimgray;" > < / span > < span style = "color:#3333FF;" > jq< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > .< / span >
< span style = "font-weight:bold;" > [
{
< / span > < span style = "font-weight:bold;color:#3333FF;" > " id" < / span > < span style = "font-weight:bold;" > : < / span > 1< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isPaused" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isNamed" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " name" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " Test 1" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " duration" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " 1w" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " account_id" < / span > < span style = "font-weight:bold;" > : < / span > 10< span style = "font-weight:bold;" >
}< / span > < span style = "font-weight:bold;" > ,
{
< / span > < span style = "font-weight:bold;color:#3333FF;" > " id" < / span > < span style = "font-weight:bold;" > : < / span > 4< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isPaused" < / span > < span style = "font-weight:bold;" > : < / span > 0< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isNamed" < / span > < span style = "font-weight:bold;" > : < / span > 1< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " name" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " Test 3" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " duration" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " 1w" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " account_id" < / span > < span style = "font-weight:bold;" > : < / span > 5< span style = "font-weight:bold;" >
}< / span > < span style = "font-weight:bold;" >
]< / span >
< span style = "color:dimgray;" > < / span > < span style = "filter: contrast(70%) brightness(190%);color:lime;" > user< / span > @debian-laptop < span style = "color:lime;" > ~/D/f/t/f/d/m/e/s/restful-server< / span > (master)> < span style = "color:#3333FF;" > curl< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -X< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > PUT< / span > < span style = "color:dimgray;" > < / span > \
< span style = "color:aqua;" > -d< / span > < span style = "color:dimgray;" > < / span > < span style = "color:yellow;" > '{" isPaused" : true,
" isNamed" : true,
" name" : " Test 4" ,
" duration" : " 2w" }'< / span > < span style = "color:dimgray;" > < / span > \
< span style = "color:aqua;" > --header< / span > < span style = "color:dimgray;" > < / span > < span style = "color:yellow;" > " Content-Type: application/json" < / span > < span style = "color:dimgray;" > < / span > \
< span style = "color:aqua;" > -s< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > http://127.0.0.1:5000/api/survey/4 < / span >
{" success" : true}
< span style = "color:dimgray;" > < / span > < span style = "filter: contrast(70%) brightness(190%);color:lime;" > user< / span > @debian-laptop < span style = "color:lime;" > ~/D/f/t/f/d/m/e/s/restful-server< / span > (master)> < / span > < span style = "color:#3333FF;" > curl< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -s< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > http://127.0.0.1:5000/api/survey/4< / span > < span style = "color:dimgray;" > < / span > < span style = "color:lime;" > |< / span > < span style = "color:dimgray;" > < / span > < span style = "color:#3333FF;" > jq< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > .< / span > < span style = "color:dimgray;" > < / span >
< span style = "font-weight:bold;" > [
{
< / span > < span style = "font-weight:bold;color:#3333FF;" > " id" < / span > < span style = "font-weight:bold;" > : < / span > 4< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isPaused" < / span > < span style = "font-weight:bold;" > : < / span > 1< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " isNamed" < / span > < span style = "font-weight:bold;" > : < / span > 1< span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " name" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " Test 4" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " duration" < / span > < span style = "font-weight:bold;" > : < / span > < span style = "color:lime;" > " 2w" < / span > < span style = "font-weight:bold;" > ,
< / span > < span style = "font-weight:bold;color:#3333FF;" > " account_id" < / span > < span style = "font-weight:bold;" > : < / span > 5< span style = "font-weight:bold;" >
}< / span > < span style = "font-weight:bold;" >
]< / span >
< span style = "color:dimgray;" > < / span > < span style = "filter: contrast(70%) brightness(190%);color:lime;" > user< / span > @debian-laptop < span style = "color:lime;" > ~/D/f/t/f/d/m/e/s/restful-server< / span > (master)> < span style = "color:#3333FF;" > curl< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -v< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -X< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > DELETE< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > --header< / span > < span style = "color:dimgray;" > < / span > < span style = "color:yellow;" > " Content-Type: application/json" < / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > -d< / span > < span style = "color:dimgray;" > < / span > < span style = "color:yellow;" > '{}'< / span > < span style = "color:dimgray;" > < / span > < span style = "color:aqua;" > http://127.0.0.1:5000/api/survey/4 < / span >
* Trying 127.0.0.1:5000...
* Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0)
> DELETE /api/survey/4 HTTP/1.1
> Host: 127.0.0.1:5000
> User-Agent: curl/7.88.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 2
>
< HTTP/1.1 200 OK
< Server: Werkzeug/3.0.3 Python/3.11.2
< Date: Tue, 21 May 2024 14:45:09 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 94
< Connection: close
<
[{'id': 4, 'isPaused': 1, 'isNamed': 1, 'name': 'Test 4', 'duration': '2w', 'account_id': 5}]
* Closing connection 0
< span style = "color:dimgray;" > < / span > < span style = "filter: contrast(70%) brightness(190%);color:lime;" > user< / span > @debian-laptop < span style = "color:lime;" > ~/D/f/t/f/d/m/e/s/restful-server< / span > (master)>
< / pre >
Бачимо, що ми можемо отримувати інформацію про окремі опитування, змінювати та видаляти їх.