include static folder and update path for different machines

This commit is contained in:
Yisroel Baum 2024-09-29 15:02:31 +03:00
parent 3bc413916c
commit d9f0b90474
29 changed files with 13 additions and 6 deletions

3
.gitignore vendored
View file

@ -1,2 +1 @@
**/__pycache__/ **/__pycache__/
static/

View file

@ -7,6 +7,14 @@ import os
import openpyxl import openpyxl
import time import time
def get_uploads_path():
path1 = 'C:/Users/Lenovo/Desktop/BudgetingApp/app/static/uploadable/'
path2 = '/home/yisroel2/Desktop/budgetingApp/app/static/uploadable/'
for p in [path1, path2]:
if os.path.exists(p):
path = p
break
return path
@app.route('/') @app.route('/')
def home(): def home():
@ -16,7 +24,7 @@ def home():
notes = db.session.execute(select(LineItem.note)).all() notes = db.session.execute(select(LineItem.note)).all()
vendors = db.session.execute(select(Vendor)).all() vendors = db.session.execute(select(Vendor)).all()
budget_categories = db.session.execute(select(BudgetCategory)).all() budget_categories = db.session.execute(select(BudgetCategory)).all()
files = os.listdir('C:/Users/Lenovo/Desktop/BudgetingApp/app/static/uploadable') files = os.listdir(get_uploads_path())
return render_template('index.html', return render_template('index.html',
files=files, files=files,
notes=notes, notes=notes,
@ -26,7 +34,7 @@ def home():
@app.route('/upload_file/<filename>') @app.route('/upload_file/<filename>')
def upload_file(filename): def upload_file(filename):
file_path = 'C:/Users/Lenovo/Desktop/BudgetingApp/app/static/uploadable/' + filename file_path = get_uploads_path() + filename
xl = openpyxl.load_workbook(file_path, read_only=True) xl = openpyxl.load_workbook(file_path, read_only=True)
wb = xl.worksheets[0] wb = xl.worksheets[0]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -6,10 +6,10 @@ import os
def engineer(): def engineer():
path1 = 'C:/Users/Lenovo/Desktop/BudgetingApp/instance/site.db' path1 = 'C:/Users/Lenovo/Desktop/BudgetingApp/instance/site.db'
# path2 = '' path2 = '/home/yisroel2/Desktop/budgetingApp/instance/site.db'
# path3 = '' # path3 = ''
for p in [path1]: for p in [path1, path2]:
if os.path.exists(p): if os.path.exists(p):
path = p path = p
break break