Merge branch 'dev-anish' of http://gitea.lcepl.org/pjpatil12/Comparison_Project into dev-anish
This commit is contained in:
6
app/utils/file_utils.py
Normal file
6
app/utils/file_utils.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import os
|
||||
from app.config import Config
|
||||
|
||||
def ensure_upload_folder():
|
||||
if not os.path.exists(Config.UPLOAD_FOLDER):
|
||||
os.makedirs(Config.UPLOAD_FOLDER)
|
||||
14
app/utils/helpers.py
Normal file
14
app/utils/helpers.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# def is_logged_in(session):
|
||||
# return session.get("user_id") is not None
|
||||
|
||||
from functools import wraps
|
||||
from flask import session, redirect, url_for, flash
|
||||
|
||||
def login_required(view):
|
||||
@wraps(view)
|
||||
def wrapped_view(*args, **kwargs):
|
||||
if "user_id" not in session:
|
||||
flash("Please login first", "warning")
|
||||
return redirect(url_for("auth.login"))
|
||||
return view(*args, **kwargs)
|
||||
return wrapped_view
|
||||
10
app/utils/plot_utils.py
Normal file
10
app/utils/plot_utils.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import base64
|
||||
from io import BytesIO
|
||||
import matplotlib
|
||||
matplotlib.use("Agg")
|
||||
|
||||
def plot_to_base64(plt):
|
||||
img = BytesIO()
|
||||
plt.savefig(img, format="png", bbox_inches="tight")
|
||||
img.seek(0)
|
||||
return base64.b64encode(img.read()).decode("utf-8")
|
||||
Reference in New Issue
Block a user