2023-09-14 17:46:46 +04:00
|
|
|
|
from flask import Flask, redirect, url_for, request, render_template
|
2023-09-23 14:27:08 +04:00
|
|
|
|
from LabWork01.FuncLoad import createDataFrame
|
2023-09-14 17:46:46 +04:00
|
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
2023-09-23 14:27:08 +04:00
|
|
|
|
#сразу загружаем весь док, чтобы потом просто прыгать по нему
|
|
|
|
|
listShops = createDataFrame()
|
|
|
|
|
|
|
|
|
|
#список типов данных по столбцам
|
|
|
|
|
listTypes = listShops.dtypes.to_list()
|
|
|
|
|
|
|
|
|
|
#формируем записи о кол-ве пустых ячеек в каждом столбце
|
|
|
|
|
countNull = listShops.isnull().sum()
|
|
|
|
|
|
2023-09-14 17:46:46 +04:00
|
|
|
|
@app.route("/")
|
|
|
|
|
def home():
|
2023-09-23 14:27:08 +04:00
|
|
|
|
return render_template('main_page.html', context=[], listTypes=listTypes, countNull=countNull, firstColumn=1, secondColumn=4)
|
2023-09-14 17:46:46 +04:00
|
|
|
|
|
|
|
|
|
@app.route("/showDiapason", methods=['GET','POST'])
|
|
|
|
|
def numtext():
|
|
|
|
|
data = request.args
|
|
|
|
|
|
2023-09-23 14:27:08 +04:00
|
|
|
|
#получаем срез и таблицы по введёным параметрам
|
|
|
|
|
newListShops = listShops.iloc[int(data['firstRow'])-1:int(data['secondRow']), int(data['firstColumn']):int(data['secondColumn'])+1]
|
|
|
|
|
|
|
|
|
|
_range = range(int(data['firstColumn']), int(data['secondColumn'])+1)
|
|
|
|
|
|
|
|
|
|
#список списков для шаблона
|
|
|
|
|
totalList = []
|
|
|
|
|
|
|
|
|
|
print(countNull[1])
|
|
|
|
|
|
|
|
|
|
#формирование 4-х списков для шаблонизатора
|
|
|
|
|
if 1 in _range:
|
|
|
|
|
listStoreArea = newListShops['Store_Area'].to_list()
|
|
|
|
|
|
|
|
|
|
totalList.append(listStoreArea)
|
|
|
|
|
|
|
|
|
|
if 2 in _range:
|
|
|
|
|
listItemsAvailable = newListShops['Items_Available'].to_list()
|
|
|
|
|
|
|
|
|
|
totalList.append(listItemsAvailable)
|
|
|
|
|
|
|
|
|
|
if 3 in _range:
|
|
|
|
|
listDailyCustomerCount = newListShops['Daily_Customer_Count'].to_list()
|
|
|
|
|
|
|
|
|
|
totalList.append(listDailyCustomerCount)
|
|
|
|
|
|
|
|
|
|
if 4 in _range:
|
|
|
|
|
listStoreSales = newListShops['Store_Sales'].to_list()
|
|
|
|
|
|
|
|
|
|
totalList.append(listStoreSales)
|
2023-09-14 17:46:46 +04:00
|
|
|
|
|
|
|
|
|
if int(data['firstRow']) and int(data['secondRow']) and int(data['firstColumn']) and int(data['secondColumn']):
|
2023-09-23 14:27:08 +04:00
|
|
|
|
return render_template('main_page.html', context=totalList, listTypes=listTypes, countNull=countNull,
|
|
|
|
|
firstColumn=int(data['firstColumn']), secondColumn=int(data['secondColumn']),
|
|
|
|
|
firstRow=int(data['firstRow']), secondRow=int(data['secondRow']))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
home()
|
2023-09-14 17:46:46 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__=="__main__":
|
|
|
|
|
app.run(debug=True)
|
2023-09-14 14:30:19 +04:00
|
|
|
|
|