Skip to content

Commit

Permalink
feat: Add loading by python-dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdur-rahmaanJ committed Jul 8, 2024
1 parent ce15457 commit c310cd9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
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

0 comments on commit c310cd9

Please sign in to comment.