From ef41bbba39db2a11d723f21b4a1fe73e0987e592 Mon Sep 17 00:00:00 2001 From: Denis1505 Date: Thu, 25 Aug 2022 14:50:37 +0300 Subject: [PATCH 1/3] [#H24]. Created first part --- .../home_work/flask_hw/storage.json | 1247 ----------------- 1 file changed, 1247 deletions(-) delete mode 100644 Shops/sport_atribute_shop/home_work/flask_hw/storage.json diff --git a/Shops/sport_atribute_shop/home_work/flask_hw/storage.json b/Shops/sport_atribute_shop/home_work/flask_hw/storage.json deleted file mode 100644 index 5f8c114..0000000 --- a/Shops/sport_atribute_shop/home_work/flask_hw/storage.json +++ /dev/null @@ -1,1247 +0,0 @@ -{ - "4_task": { - "authors": { - "1": { - "name": "Уладзімер Караткевіч", - "birth_date": "26-11-1930", - "death_date": "25-07-1984" - }, - "2": { - "name": "Іван Луцевіч", - "birth_date": "07-07-1882", - "death_date": "28-06-1942" - }, - "3": { - "name": "Канстанцін Міцкевіч", - "birth_date": "03-11-1882", - "death_date": "13-08-1956" - } - - }, - "books": { - "1": { - "title": "Новая зямля", - "author_id": 3, - "year": 1923 - }, - "2": { - "title": "Сымон-музыка", - "author_id": 3, - "year": 1925 - }, - "3": { - "title": "На ростанях", - "author_id": 3, - "year": 1955 - }, - "4": { - "title": "Спадчына", - "author_id": 2, - "year": 1922 - }, - "5": { - "title": "Курган", - "author_id": 2, - "year": 1910 - }, - "6": { - "title": "Магіла льва", - "author_id": 2, - "year": 1913 - }, - "7": { - "title": "Хрыстос прызямліўся ў Гародні", - "author_id": 1, - "year": 1966 - }, - "8": { - "title": "Каласы пад сярпом тваім", - "author_id": 1, - "year": 1964 - }, - "9": { - "title": "Дзікае паляванне караля Стаха", - "author_id": 1, - "year": 1958 - } - } - }, - "5_task": { - "employees": [ - { - "name": "Alex", - "id": 1, - "role": "developer", - "department": "SDK" - }, - { - "name": "Alice", - "id": 2, - "role": "manager", - "department": "SDK" - }, - { - "name": "Bob", - "id": 1, - "role": "developer", - "department": "product" - } - ] - }, - "3_task": { - "schedule": { - "monday": [ - { - "begin_time": "06-06-2022, 12:20:00", - "end_time": "06-06-2022, 14:00:00", - "title": "Interview ItechArt", - "description": "Собеседование кандидата", - "location": "zoom.us" - }, - { - "begin_time": "13-06-2022, 14:10:00", - "end_time": "13-06-2022, 15:00:00", - "title": "Daily", - "description": null, - "location": "teams.com" - } - - ], - "tuesday": [ - { - "begin_time": "07-06-2022, 12:20:00", - "end_time": "07-06-2022, 14:00:00", - "title": "Retro LeverX", - "description": "Retro", - "location": "zoom.us" - }, - { - "begin_time": "14-06-2022, 15:10:00", - "end_time": "14-06-2022, 16:00:00", - "title": "Daily", - "description": null, - "location": "teams.com" - } - ], - "wednesday":[ - { - "begin_time": "08-06-2022, 12:20:00", - "end_time": "08-06-2022, 14:00:00", - "title": "Demo CoronaPay", - "description": "Demo", - "location": "zoom.us" - }, - { - "begin_time": "15-06-2022, 15:10:00", - "end_time": "15-06-2022, 16:00:00", - "title": "Daily", - "description": null, - "location": "teams.com" - } - ], - "thursday": [ - { - "begin_time": "09-06-2022, 12:20:00", - "end_time": "09-06-2022, 14:00:00", - "title": "Interview IsSoft", - "description": "Simple tech interview", - "location": "zoom.us" - }, - { - "begin_time": "16-06-2022, 15:10:00", - "end_time": "16-06-2022, 16:00:00", - "title": "Daily", - "description": null, - "location": "teams.com" - } - ], - "friday": [ - { - "begin_time": "10-06-2022, 12:20:00", - "end_time": "10-06-2022, 14:00:00", - "title": "Demo CoronaPay", - "description": "Demo", - "location": "zoom.us" - }, - { - "begin_time": "17-06-2022, 15:10:00", - "end_time": "17-06-2022, 16:00:00", - "title": "Daily", - "description": null, - "location": "teams.com" - } - ], - "saturday": [ - - ], - "sunday": [ - - ] - } - }, - "1_task": {}, - "2_task": { - "cars":[ - { - "id": 101068323, - "price": { - "currency": "usd", - "amount": 22300 - }, - "publishedAt": "2022-05-01T18:59:04+0000", - "properties": [ - { - "value": "Nissan", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Leaf", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "II", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2017", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": true, - "id": 30, - "name": "rain_detector", - "fallbackType": "boolean" - }, - { - "value": "\u0442\u043a\u0430\u043d\u044c", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101300695, - "price": { - "currency": "usd", - "amount": 2600 - }, - "publishedAt": "2022-06-11T10:31:20+0000", - "properties": [ - { - "value": "BMW", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "3 \u0441\u0435\u0440\u0438\u044f", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "E36", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "1997", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u0436\u0430", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 100881417, - "price": { - "currency": "usd", - "amount": 19500 - }, - "publishedAt": "2022-03-01T18:07:58+0000", - "properties": [ - { - "value": "BMW", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "7 \u0441\u0435\u0440\u0438\u044f", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "F01, F04", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2011", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": true, - "id": 30, - "name": "rain_detector", - "fallbackType": "boolean" - }, - { - "value": "\u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u0436\u0430", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101241893, - "price": { - "currency": "usd", - "amount": 13650 - }, - "publishedAt": "2022-06-03T10:45:32+0000", - "properties": [ - { - "value": "Chevrolet", - "id": 110, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Malibu", - "id": 111, - "name": "model", - "fallbackType": "string" - }, - { - "value": "IX", - "id": 112, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2018", - "id": 114, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u0442\u043a\u0430\u043d\u044c", - "id": 129, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101300669, - "price": { - "currency": "usd", - "amount": 999 - }, - "publishedAt": "2022-06-11T10:25:46+0000", - "properties": [ - { - "value": "Daewoo", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Nexia", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "I", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2006", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u0432\u0435\u043b\u044e\u0440", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101300660, - "price": { - "currency": "usd", - "amount": 2350 - }, - "publishedAt": "2022-06-11T10:17:31+0000", - "properties": [ - { - "value": "Volvo", - "id": 110, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "S40", - "id": 111, - "name": "model", - "fallbackType": "string" - }, - { - "value": "I", - "id": 112, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "1997", - "id": 114, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u0442\u043a\u0430\u043d\u044c", - "id": 129, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 100984203, - "price": { - "currency": "usd", - "amount": 12650 - }, - "publishedAt": "2022-04-07T06:55:17+0000", - "properties": [ - { - "value": "Ford", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Focus", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "III \u00b7 \u0420\u0435\u0441\u0442\u0430\u0439\u043b\u0438\u043d\u0433", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2017", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": true, - "id": 30, - "name": "rain_detector", - "fallbackType": "boolean" - }, - { - "value": "\u0442\u043a\u0430\u043d\u044c", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101285540, - "price": { - "currency": "usd", - "amount": 3650 - }, - "publishedAt": "2022-06-09T19:37:35+0000", - "properties": [ - { - "value": "Toyota", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Avensis", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "I (T220) \u00b7 \u0420\u0435\u0441\u0442\u0430\u0439\u043b\u0438\u043d\u0433", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2001", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u0432\u0435\u043b\u044e\u0440", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101233095, - "price": { - "currency": "usd", - "amount": 7980 - }, - "publishedAt": "2022-06-05T13:21:45+0000", - "properties": [ - { - "value": "Mercedes-Benz", - "id": 218, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Viano", - "id": 219, - "name": "model", - "fallbackType": "string" - }, - { - "value": "W639", - "id": 220, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2004", - "id": 222, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u0436\u0430", - "id": 237, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101170719, - "price": { - "currency": "usd", - "amount": 15600 - }, - "publishedAt": "2022-05-19T15:55:18+0000", - "properties": [ - { - "value": "Nissan", - "id": 110, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Qashqai", - "id": 111, - "name": "model", - "fallbackType": "string" - }, - { - "value": "II", - "id": 112, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2014", - "id": 114, - "name": "year", - "fallbackType": "string" - }, - { - "value": true, - "id": 138, - "name": "rain_detector", - "fallbackType": "boolean" - }, - { - "value": "\u0442\u043a\u0430\u043d\u044c", - "id": 129, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 100888228, - "price": { - "currency": "usd", - "amount": 3350 - }, - "publishedAt": "2022-05-03T15:58:36+0000", - "properties": [ - { - "value": "Skoda", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Fabia", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "6Y", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2000", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u0442\u043a\u0430\u043d\u044c", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101300591, - "price": { - "currency": "usd", - "amount": 5650 - }, - "publishedAt": "2022-06-11T09:59:53+0000", - "properties": [ - { - "value": "Peugeot", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "207", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "I", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2008", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u0442\u043a\u0430\u043d\u044c", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101181314, - "price": { - "currency": "usd", - "amount": 5300 - }, - "publishedAt": "2022-05-24T19:52:35+0000", - "properties": [ - { - "value": "Jaguar", - "id": 218, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "X-Type", - "id": 219, - "name": "model", - "fallbackType": "string" - }, - { - "value": "2002", - "id": 222, - "name": "year", - "fallbackType": "string" - }, - { - "value": true, - "id": 246, - "name": "rain_detector", - "fallbackType": "boolean" - }, - { - "value": "\u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u0436\u0430", - "id": 237, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101176648, - "price": { - "currency": "usd", - "amount": 2750 - }, - "publishedAt": "2022-05-22T18:34:22+0000", - "properties": [ - { - "value": "Plymouth", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Grand Voyager", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "III", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "1999", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u0432\u0435\u043b\u044e\u0440", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101082917, - "price": { - "currency": "usd", - "amount": 16800 - }, - "publishedAt": "2022-05-05T08:38:21+0000", - "properties": [ - { - "value": "MINI", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Clubman", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "II", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2018", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": true, - "id": 30, - "name": "rain_detector", - "fallbackType": "boolean" - }, - { - "value": "\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 100951001, - "price": { - "currency": "usd", - "amount": 15000 - }, - "publishedAt": "2022-03-27T13:08:32+0000", - "properties": [ - { - "value": "Kia", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Sorento", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "II", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2009", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u0442\u043a\u0430\u043d\u044c", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101300515, - "price": { - "currency": "usd", - "amount": 9350 - }, - "publishedAt": "2022-06-11T09:16:28+0000", - "properties": [ - { - "value": "Peugeot", - "id": 218, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "3008", - "id": 219, - "name": "model", - "fallbackType": "string" - }, - { - "value": "I", - "id": 220, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2012", - "id": 222, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u0442\u043a\u0430\u043d\u044c", - "id": 237, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101129287, - "price": { - "currency": "usd", - "amount": 4450 - }, - "publishedAt": "2022-05-16T09:56:47+0000", - "properties": [ - { - "value": "Suzuki", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Swift", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "III", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2005", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u0442\u043a\u0430\u043d\u044c", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101226998, - "price": { - "currency": "usd", - "amount": 16900 - }, - "publishedAt": "2022-05-31T19:57:25+0000", - "properties": [ - { - "value": "Mercedes-Benz", - "id": 218, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "E-\u041a\u043b\u0430\u0441\u0441", - "id": 219, - "name": "model", - "fallbackType": "string" - }, - { - "value": "W212, S212, C207, A207", - "id": 220, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2011", - "id": 222, - "name": "year", - "fallbackType": "string" - }, - { - "value": true, - "id": 246, - "name": "rain_detector", - "fallbackType": "boolean" - }, - { - "value": "\u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u0436\u0430", - "id": 237, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101248767, - "price": { - "currency": "usd", - "amount": 1000 - }, - "publishedAt": "2022-06-06T11:29:53+0000", - "properties": [ - { - "value": "Daewoo", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Nubira", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "J100", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "1998", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u0432\u0435\u043b\u044e\u0440", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101173406, - "price": { - "currency": "usd", - "amount": 11000 - }, - "publishedAt": "2022-05-20T23:18:49+0000", - "properties": [ - { - "value": "Honda", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "CR-V", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "II \u00b7 \u0420\u0435\u0441\u0442\u0430\u0439\u043b\u0438\u043d\u0433", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2006", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": true, - "id": 30, - "name": "rain_detector", - "fallbackType": "boolean" - }, - { - "value": "\u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u0436\u0430", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101149805, - "price": { - "currency": "usd", - "amount": 13450 - }, - "publishedAt": "2022-05-18T08:20:34+0000", - "properties": [ - { - "value": "Kia", - "id": 218, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "Carens", - "id": 219, - "name": "model", - "fallbackType": "string" - }, - { - "value": "III", - "id": 220, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2014", - "id": 222, - "name": "year", - "fallbackType": "string" - }, - { - "value": true, - "id": 246, - "name": "rain_detector", - "fallbackType": "boolean" - }, - { - "value": "\u0442\u043a\u0430\u043d\u044c", - "id": 237, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101216781, - "price": { - "currency": "usd", - "amount": 21950 - }, - "publishedAt": "2022-05-30T09:21:30+0000", - "properties": [ - { - "value": "Peugeot", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "508", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "II", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2018", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": true, - "id": 30, - "name": "rain_detector", - "fallbackType": "boolean" - }, - { - "value": "\u0442\u043a\u0430\u043d\u044c", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 101300381, - "price": { - "currency": "usd", - "amount": 2950 - }, - "publishedAt": "2022-06-11T08:12:30+0000", - "properties": [ - { - "value": "Peugeot", - "id": 2, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "607", - "id": 3, - "name": "model", - "fallbackType": "string" - }, - { - "value": "I", - "id": 4, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2003", - "id": 6, - "name": "year", - "fallbackType": "string" - }, - { - "value": "\u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u0436\u0430", - "id": 21, - "name": "interior_material", - "fallbackType": "string" - } - ] - }, - { - "id": 100865007, - "price": { - "currency": "usd", - "amount": 22900 - }, - "publishedAt": "2022-03-04T18:49:11+0000", - "properties": [ - { - "value": "Mercedes-Benz", - "id": 218, - "name": "brand", - "fallbackType": "string" - }, - { - "value": "M-\u041a\u043b\u0430\u0441\u0441 AMG", - "id": 219, - "name": "model", - "fallbackType": "string" - }, - { - "value": "W164 \u00b7 \u0420\u0435\u0441\u0442\u0430\u0439\u043b\u0438\u043d\u0433", - "id": 220, - "name": "generation", - "fallbackType": "string" - }, - { - "value": "2008", - "id": 222, - "name": "year", - "fallbackType": "string" - }, - { - "value": true, - "id": 246, - "name": "rain_detector", - "fallbackType": "boolean" - }, - { - "value": "\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b", - "id": 237, - "name": "interior_material", - "fallbackType": "string" - } - ] - } - ] - } -} \ No newline at end of file From b9bd962dc8108acac69dc3bb82747347cbd2eb91 Mon Sep 17 00:00:00 2001 From: Denis1505 Date: Thu, 25 Aug 2022 14:54:59 +0300 Subject: [PATCH 2/3] [#H24]. Created first part --- Shops/sport_atribute_shop/flask_app/config.py | 10 +++ Shops/sport_atribute_shop/flask_app/run.py | 6 ++ .../sport_atribute_shop/flask_app/service.py | 25 +++++++ .../flask_app/storage.json | 1 + .../sport_atribute_shop/flask_app/storage.py | 23 +++++++ Shops/sport_atribute_shop/flask_app/views.py | 16 +++++ .../home_work/flask_hw/[#H17]Flask_HW.py | 22 ------- .../home_work/flask_hw/[#H17]Flask_HW2.py | 66 ------------------- 8 files changed, 81 insertions(+), 88 deletions(-) create mode 100644 Shops/sport_atribute_shop/flask_app/config.py create mode 100644 Shops/sport_atribute_shop/flask_app/run.py create mode 100644 Shops/sport_atribute_shop/flask_app/service.py create mode 100644 Shops/sport_atribute_shop/flask_app/storage.json create mode 100644 Shops/sport_atribute_shop/flask_app/storage.py create mode 100644 Shops/sport_atribute_shop/flask_app/views.py delete mode 100644 Shops/sport_atribute_shop/home_work/flask_hw/[#H17]Flask_HW.py delete mode 100644 Shops/sport_atribute_shop/home_work/flask_hw/[#H17]Flask_HW2.py diff --git a/Shops/sport_atribute_shop/flask_app/config.py b/Shops/sport_atribute_shop/flask_app/config.py new file mode 100644 index 0000000..1d8d3a2 --- /dev/null +++ b/Shops/sport_atribute_shop/flask_app/config.py @@ -0,0 +1,10 @@ +from flask import Flask +from storage import Storage + +storage = Storage("storage.json") +app = Flask(__name__) + + +secret_key = 'hello' + + diff --git a/Shops/sport_atribute_shop/flask_app/run.py b/Shops/sport_atribute_shop/flask_app/run.py new file mode 100644 index 0000000..64f81a6 --- /dev/null +++ b/Shops/sport_atribute_shop/flask_app/run.py @@ -0,0 +1,6 @@ +from views import app + + + +if __name__ == "__main__": + app.run(debug=True, host='0.0.0.0', port=5000) \ No newline at end of file diff --git a/Shops/sport_atribute_shop/flask_app/service.py b/Shops/sport_atribute_shop/flask_app/service.py new file mode 100644 index 0000000..3c20161 --- /dev/null +++ b/Shops/sport_atribute_shop/flask_app/service.py @@ -0,0 +1,25 @@ +import hashlib +from config import storage, secret_key +import jwt + +def hash_md5(data): + return hashlib.md5(data.encode('utf-8')).hexdigest() + + +def registrate(account): + account['password'] = hash_md5(account.get('password')) + storage.add(account) + +def login(account): + email = account.get("email") + data = storage.get_by_email(email) + password = hash_md5(account.get("password")) + saved_password = data.get("password") + if password == saved_password: + return make_jwt(data) + + +def make_jwt(data): + return jwt.encode(data, secret_key, algorithm='HS256') + + diff --git a/Shops/sport_atribute_shop/flask_app/storage.json b/Shops/sport_atribute_shop/flask_app/storage.json new file mode 100644 index 0000000..778ffb1 --- /dev/null +++ b/Shops/sport_atribute_shop/flask_app/storage.json @@ -0,0 +1 @@ +[{"password": "900150983cd24fb0d6963f7d28e17f72", "email": "qwerty@qwerty.com"}, {"password": "3944b025c9ca7eec3154b44666ae04a0", "email": "qwerty1@qwerty.com"}, {"email": "denis@den.com", "password": "c3875d07f44c422f3b3bc019c23e16ae"}, {"email": "denis@den.com", "password": "c3875d07f44c422f3b3bc019c23e16ae"}, {"email": "denis@den.com", "password": "52103037f7230187f89ce58d5334cdb6"}] \ No newline at end of file diff --git a/Shops/sport_atribute_shop/flask_app/storage.py b/Shops/sport_atribute_shop/flask_app/storage.py new file mode 100644 index 0000000..157e806 --- /dev/null +++ b/Shops/sport_atribute_shop/flask_app/storage.py @@ -0,0 +1,23 @@ +import json + +class Storage: + + def __init__(self, path): + self.path = path + + def get(self, *args, **kwargs): + with open (self.path, "r") as file: + data = json.load(file) + return data + + def get_by_email(self, email): + data = self.get() + return list(filter(lambda acc: acc.get("email") == email, data))[0] + + def add(self, data): + storage_data = self.get() + storage_data.append(data) + with open(self.path, "w") as file: + json.dump(storage_data, file) + + \ No newline at end of file diff --git a/Shops/sport_atribute_shop/flask_app/views.py b/Shops/sport_atribute_shop/flask_app/views.py new file mode 100644 index 0000000..39079c5 --- /dev/null +++ b/Shops/sport_atribute_shop/flask_app/views.py @@ -0,0 +1,16 @@ +from config import app +from flask import request, jsonify, make_response +from service import registrate, login as log + +@app.route('/login', methods=["POST"]) +def login(): + data = request.get_json() + token = log(data) + return make_response(jsonify({"token": token}), 200) + + +@app.route('/reg', methods=["POST"]) +def reg(): + data = request.get_json() + registrate(data) + return make_response(jsonify({"result": 'OK'}), 201) \ No newline at end of file diff --git a/Shops/sport_atribute_shop/home_work/flask_hw/[#H17]Flask_HW.py b/Shops/sport_atribute_shop/home_work/flask_hw/[#H17]Flask_HW.py deleted file mode 100644 index 302cb75..0000000 --- a/Shops/sport_atribute_shop/home_work/flask_hw/[#H17]Flask_HW.py +++ /dev/null @@ -1,22 +0,0 @@ -""" -Сделайте так, чтобы при переходе на страницу -localhost:5000/hello/alex/age/100 -На странице повлялся текст: -Hello Alex! Your age is 100! -А при переходе на -localhost:5000/hello/bob/age/1 -Hello Bob! Your age is 1! -""" - -from flask import Flask - - -app = Flask(__name__) - - -@app.route("/hello//age/") -def index(name: str, age: int): - return f"Hello {name.capitalize()}! Your age is {age}!" - - -app.run(port=5000, debug=True) \ No newline at end of file diff --git a/Shops/sport_atribute_shop/home_work/flask_hw/[#H17]Flask_HW2.py b/Shops/sport_atribute_shop/home_work/flask_hw/[#H17]Flask_HW2.py deleted file mode 100644 index dcb9b90..0000000 --- a/Shops/sport_atribute_shop/home_work/flask_hw/[#H17]Flask_HW2.py +++ /dev/null @@ -1,66 +0,0 @@ -""" -Запустите приложение, посмотрите, как оно сейчас работает -Сделайте так, чтобы при переходе по -localhost:5000/cars -Выводился json следующего формата: -{ - "cars_number": 25, - "cars": [ - { - "id": 101068323, - "price_usd": 22300, - "brand": "Nissan", - "model": "Leaf", - "generation": "II", - "year": "2017", - "rain_detector": true, - "interior_material": "ткань", - "created_advert": "2022-05-01T18:59:04+0000" - }, - ... - ] -} -(extra) Дабавьте фильтрацию через адресную строку по всем этим параметрам. -""" - -import json -from typing import Dict -from flask import Flask -from flask import jsonify - - -app = Flask(__name__) - - -def get_cars(): - with open("storage.json") as file: - data = json.load(file).get("2_task").get("cars") - return data - -def get_car(data: Dict)-> list: - return [ - { - "id": car.get("id", {}), - "price_usd": car.get("price", {}).get("amount", {}), - "brand": car.get("properties", {})[0].get("value", {}), - "model": car.get("properties", {})[1].get("value", {}), - "generation": car.get("properties", {})[2].get("value", {}), - "year": car.get("properties", {})[3].get("value", {}), - "rain_detector": car.get("properties", {})[4].get("value", {}), - "interior_material": car.get("properties", {})[5].get("value", {}), - "created_advert": car.get("publishedAt", {}) - } for car in data - ] - -@app.route("/cars") -def get_cars_view(): - car = get_cars() - cars = get_car(car) - return jsonify( - { - "cars_number": len(cars), - "cars": cars - } - ) - -app.run(port=5000) \ No newline at end of file From 40cd2448aa83f5eb91fca9e6c07f5a6f33677b09 Mon Sep 17 00:00:00 2001 From: Denis9505 Date: Fri, 9 Sep 2022 07:33:08 +0300 Subject: [PATCH 3/3] [H24]. Completed HW --- Shops/sport_atribute_shop/flask_app/config.py | 4 +--- .../sport_atribute_shop/flask_app/service.py | 20 ++++++++++++++---- .../flask_app/storage.json | 2 +- .../sport_atribute_shop/flask_app/storage.py | 10 ++++++--- Shops/sport_atribute_shop/flask_app/views.py | 21 +++++++++++++++---- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/Shops/sport_atribute_shop/flask_app/config.py b/Shops/sport_atribute_shop/flask_app/config.py index 1d8d3a2..d1b334d 100644 --- a/Shops/sport_atribute_shop/flask_app/config.py +++ b/Shops/sport_atribute_shop/flask_app/config.py @@ -5,6 +5,4 @@ app = Flask(__name__) -secret_key = 'hello' - - +secret_key = '' diff --git a/Shops/sport_atribute_shop/flask_app/service.py b/Shops/sport_atribute_shop/flask_app/service.py index 3c20161..ccdaebe 100644 --- a/Shops/sport_atribute_shop/flask_app/service.py +++ b/Shops/sport_atribute_shop/flask_app/service.py @@ -2,13 +2,27 @@ from config import storage, secret_key import jwt + def hash_md5(data): return hashlib.md5(data.encode('utf-8')).hexdigest() def registrate(account): + result = { + "error": True, + "message": "User already exists." + } account['password'] = hash_md5(account.get('password')) - storage.add(account) + email = account.get("email") + storage_account = storage.get_by_email(email) + if storage_account is None: + storage.add(account) + result = { + 'error': False, + 'message': "OK!" + } + return result + def login(account): email = account.get("email") @@ -17,9 +31,7 @@ def login(account): saved_password = data.get("password") if password == saved_password: return make_jwt(data) - + def make_jwt(data): return jwt.encode(data, secret_key, algorithm='HS256') - - diff --git a/Shops/sport_atribute_shop/flask_app/storage.json b/Shops/sport_atribute_shop/flask_app/storage.json index 778ffb1..fe51488 100644 --- a/Shops/sport_atribute_shop/flask_app/storage.json +++ b/Shops/sport_atribute_shop/flask_app/storage.json @@ -1 +1 @@ -[{"password": "900150983cd24fb0d6963f7d28e17f72", "email": "qwerty@qwerty.com"}, {"password": "3944b025c9ca7eec3154b44666ae04a0", "email": "qwerty1@qwerty.com"}, {"email": "denis@den.com", "password": "c3875d07f44c422f3b3bc019c23e16ae"}, {"email": "denis@den.com", "password": "c3875d07f44c422f3b3bc019c23e16ae"}, {"email": "denis@den.com", "password": "52103037f7230187f89ce58d5334cdb6"}] \ No newline at end of file +[] diff --git a/Shops/sport_atribute_shop/flask_app/storage.py b/Shops/sport_atribute_shop/flask_app/storage.py index 157e806..1e87aca 100644 --- a/Shops/sport_atribute_shop/flask_app/storage.py +++ b/Shops/sport_atribute_shop/flask_app/storage.py @@ -1,5 +1,6 @@ import json + class Storage: def __init__(self, path): @@ -12,12 +13,15 @@ def get(self, *args, **kwargs): def get_by_email(self, email): data = self.get() - return list(filter(lambda acc: acc.get("email") == email, data))[0] + result = list(filter(lambda acc: acc.get("email") == email, data)) + if not result: + result = None + else: + result = result[0] + return result def add(self, data): storage_data = self.get() storage_data.append(data) with open(self.path, "w") as file: json.dump(storage_data, file) - - \ No newline at end of file diff --git a/Shops/sport_atribute_shop/flask_app/views.py b/Shops/sport_atribute_shop/flask_app/views.py index 39079c5..880ba2e 100644 --- a/Shops/sport_atribute_shop/flask_app/views.py +++ b/Shops/sport_atribute_shop/flask_app/views.py @@ -2,15 +2,28 @@ from flask import request, jsonify, make_response from service import registrate, login as log + @app.route('/login', methods=["POST"]) def login(): data = request.get_json() - token = log(data) - return make_response(jsonify({"token": token}), 200) + try: + token = log(data) + result = ({"token": token, + "status": "ok"}, 200) + except Exception as e: + result = ({ + "status": "error", + "detail": "Passwords or email didn't match.", + }, 400) + return make_response(jsonify(result)) @app.route('/reg', methods=["POST"]) def reg(): data = request.get_json() - registrate(data) - return make_response(jsonify({"result": 'OK'}), 201) \ No newline at end of file + code = 200 + result = registrate(data) + if result.get('error'): + code = 422 + return make_response(jsonify({"message": result.get("message")})), code + \ No newline at end of file