Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add loading by python-dotenv #525

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified reqs/app.in
Binary file not shown.
26 changes: 22 additions & 4 deletions reqs/app.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
# This file was autogenerated by uv via the following command:
# uv pip compile reqs/app.in -o reqs/app.txt
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile app.in
#
alembic==1.7.3
# via flask-migrate
click==8.0.1
# via flask
dnspython==2.1.0
# via email-validator
email-validator==1.1.3
# via shopyo
# via
# -r app.in
# shopyo
et-xmlfile==1.1.0
# via openpyxl
flask==2.2.0
# via
# -r app.in
# flask-admin
# flask-login
# flask-mailman
Expand All @@ -24,16 +31,20 @@ flask==2.2.0
flask-admin==1.6.0
# via shopyo
flask-login==0.6.2
# via shopyo
# via
# -r app.in
# shopyo
flask-mailman==0.3.0
# via shopyo
flask-marshmallow==0.14.0
# via shopyo
flask-migrate==3.1.0
# via shopyo
flask-reuploaded==1.2.0
# via -r app.in
flask-sqlalchemy==2.5.1
# via
# -r app.in
# flask-migrate
# shopyo
flask-wtf==1.0.0
Expand Down Expand Up @@ -68,12 +79,19 @@ mkdocs-material-extensions==1.0.3
numpy==1.23.2
# via pandas
openpyxl==3.0.10
# via -r app.in
pandas==2.2.2
# via -r app.in
pillow==9.2.0
# via -r app.in
pymysql==1.0.2
# via -r app.in
python-dateutil==2.8.2
# via pandas
python-dotenv==1.0.1
# via -r app.in
pythoncms==1.2.1
# via -r app.in
pytz==2022.2.1
# via pandas
shopyo==4.8.6
Expand Down
3 changes: 2 additions & 1 deletion src/shopcube/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@


def create_app(config_name="development"):

from dotenv import load_dotenv
load_dotenv()
global_template_variables = {}
global_configs = {}
app = Flask(
Expand Down
15 changes: 3 additions & 12 deletions src/shopcube/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ class BaseConfig:
)
UPLOADED_PRODUCTEXCEL_DEST = os.path.join(STATIC, "uploads")
UPLOADED_PRODUCTEXCEL_ALLOW = ("xls", "xlsx", "xlsm", "xlsb", "odf")
PASSWORD_SALT = "abcdefghi"


SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI')
SALT = os.environ.get('SALT')

class ProductionConfig(BaseConfig):
"""Configurations for production"""
Expand All @@ -61,10 +62,6 @@ class ProductionConfig(BaseConfig):
MAIL_PASSWORD = os.environ.get("MAIL_PASSWORD")
MAIL_DEFAULT_SENDER = os.environ.get("MAIL_DEFAULT_SENDER")

# database configs
SQLALCHEMY_DATABASE_URI = (
os.environ.get("SQLALCHEMY_DATABASE_URI") or "sqlite:///shopyo.db"
)


class DevelopmentConfig(BaseConfig):
Expand All @@ -88,12 +85,6 @@ class DevelopmentConfig(BaseConfig):
MAIL_PASSWORD = ""
MAIL_DEFAULT_SENDER = "[email protected]"

# database configs
SQLALCHEMY_DATABASE_URI = "sqlite:///shopyo.db"

# unknown configs
PASSWORD_SALT = "some pasword salt"


class TestingConfig(BaseConfig):
"""Configurations for testsing"""
Expand Down
Loading