From f34f013b4afaf4d387177542e011c1621931d391 Mon Sep 17 00:00:00 2001 From: ElEgEv <112943269+ElEgEv@users.noreply.github.com> Date: Thu, 14 Sep 2023 17:46:46 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=81=D1=82=D0=B0=D0=BB=D1=81=D1=8F=20?= =?UTF-8?q?=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=20=D1=82=D0=B8=D0=BF=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=B8=20=D0=BF=D1=80=D0=B8=D0=B2=D0=B5=D0=B4=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BA=20=D0=BD=D0=B8=D0=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LabWork01/FuncLoad.py | 16 ++++++++ LabWork01/LoadDB.py | 28 +++++++++++--- LabWork01/Shop.py | 11 ++++++ LabWork01/templates/main_page.html | 59 ++++++++++++++++++++++++++++++ Test.py | 2 +- 5 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 LabWork01/FuncLoad.py create mode 100644 LabWork01/Shop.py create mode 100644 LabWork01/templates/main_page.html diff --git a/LabWork01/FuncLoad.py b/LabWork01/FuncLoad.py new file mode 100644 index 0000000..ce821d2 --- /dev/null +++ b/LabWork01/FuncLoad.py @@ -0,0 +1,16 @@ +import csv +from LabWork01.Shop import Shop + +def createList(): + newListShop = [] + + file = open("../res/Stores.csv", "r") + data = list(csv.reader(file, delimiter=",")) + file.close() + + for elem in data: + newListShop.append(Shop(elem[1], elem[2], elem[3], elem[4])) + + newListShop.pop(0) + + return newListShop \ No newline at end of file diff --git a/LabWork01/LoadDB.py b/LabWork01/LoadDB.py index 155ba9a..b4dd3e9 100644 --- a/LabWork01/LoadDB.py +++ b/LabWork01/LoadDB.py @@ -1,7 +1,23 @@ -import csv +from flask import Flask, redirect, url_for, request, render_template +from LabWork01.FuncLoad import createList + +app = Flask(__name__) + +@app.route("/") +def home(): + return render_template('main_page.html', firstColumn=1, secondColumn=4) + +@app.route("/showDiapason", methods=['GET','POST']) +def numtext(): + data = request.args + + listShops = createList() + + if int(data['firstRow']) and int(data['secondRow']) and int(data['firstColumn']) and int(data['secondColumn']): + listShops = listShops[int(data['firstRow']):int(data['secondRow'])+1:1] + + return render_template('main_page.html', context=listShops, firstColumn=int(data['firstColumn']), secondColumn=int(data['secondColumn'])) + +if __name__=="__main__": + app.run(debug=True) -#тут просто прочитали все значения -with open('../res/Stores.csv', newline='') as csvfile: - spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|') - for row in spamreader: - print(', '.join(row)) \ No newline at end of file diff --git a/LabWork01/Shop.py b/LabWork01/Shop.py new file mode 100644 index 0000000..0fc8870 --- /dev/null +++ b/LabWork01/Shop.py @@ -0,0 +1,11 @@ +class Shop: + def __init__(self, store_area, items_available, daily_customer_count, store_sales): + self.store_area = store_area + self.items_available = items_available + self.daily_customer_count = daily_customer_count + self.store_sales = store_sales + + def display_shop(self): + print('Площадь: {}. Кол-во товаров: {}. Кол-во посетителей в день: {}. ' + 'Кол-во покупок: {}'.format(self.store_area, self.items_available, + self.daily_customer_count, self.store_sales)) \ No newline at end of file diff --git a/LabWork01/templates/main_page.html b/LabWork01/templates/main_page.html new file mode 100644 index 0000000..13179bb --- /dev/null +++ b/LabWork01/templates/main_page.html @@ -0,0 +1,59 @@ + + + + + Список магазинов + + + +
+
+ + + + + +
+
+
+ + + {% if firstColumn == 1 %} + + {% endif %} + {% if firstColumn <= 2 and secondColumn >= 2 %} + + {% endif %} + {% if firstColumn <= 3 and secondColumn >= 3 %} + + {% endif %} + {% if secondColumn == 4 %} + + {% endif %} + + {% for elem in context %} + + {% if firstColumn == 1 %} + + {% endif %} + {% if firstColumn <= 2 and secondColumn >= 2 %} + + {% endif %} + {% if firstColumn <= 3 and secondColumn >= 3 %} + + {% endif %} + {% if secondColumn == 4 %} + + {% endif %} + + {% endfor %} +
Площадь магазина, кв. м, doubleКол-во продукции, шт, intКол-во посетителей в день, чел., intКол-во проданных товаров, шт., int
{{ elem.store_area }}{{ elem.items_available }}{{ elem.daily_customer_count }}{{ elem.store_sales }}
+
+ + \ No newline at end of file diff --git a/Test.py b/Test.py index dedd871..ff7017e 100644 --- a/Test.py +++ b/Test.py @@ -15,4 +15,4 @@ def numtext(): return num2words(data['name'], lang='ru') if __name__=="__main__": - app.run(debug=False) \ No newline at end of file + app.run(debug=True) \ No newline at end of file