Fixed config

- config didn't work now it's working properly
- it takes config from envirionment variable FLASK_CONFIG
- if no such variable exists it uses Development config as default
This commit is contained in:
svitvojimilioni committed 2023-08-15 20:29:21 -04:00
1 parent 85a90a8fc1
commit 590a43b28e
10 files changed
+36

No files matched your search

+3
View File
@@ -1,7 +1,10 @@
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import os
app = Flask(__name__)
config_string = os.environ.get("FLASK_CONFIG", "config.DevelopmentConfig")
app.config.from_object("config.DevelopmentConifg")
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///app.db"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+29
View File
@@ -0,0 +1,29 @@
from pathlib import Path
import os
class Config:
APP_NAME = "APP_NAME"
DEBUG = False
TESTING = False
SECRET_KEY = "Change this to something secure"
APP_ROOT = os.path.join(Path(__file__).parent, "app")
DB_NAME = "app.db"
DB_USERNAME = ""
DB_PASSWORD = ""
SQLALCHEMY_DATABASE_URI = f"sqlite:///{DB_NAME}"
SQLALCHEMY_TRACK_MODIFICATIONS = False
HOST = "127.0.0.1"
UPLOAD_FOLDER = f"{APP_ROOT}/static/generated_audio"
class DevelopmentConifg(Config):
DEBUG = True
class ProductionConfig(Config):
HOST = "0.0.0.0"
class TestingConfig(Config):
TESTING = True
+4
View File
@@ -0,0 +1,4 @@
from app import app
if __name__ == '__main__':
app.run()