Did stuff with the config
This commit is contained in:
36
src/app.py
36
src/app.py
@@ -7,7 +7,7 @@ from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
|
||||
from healthcheck import HealthCheck
|
||||
from flask_cors import CORS
|
||||
|
||||
from utils.config import SENTRY_DSN, RELEASE_ID, RELEASEMODE, PORT, DEBUG, SECRET_KEY, ALLOWED_ORIGINS, SQLALCHEMY_URI
|
||||
from utils import Config
|
||||
from utils import health_database_status, security, user_datastore
|
||||
from views import ItemView, ProfileView, UploadView, IndexView
|
||||
|
||||
@@ -22,38 +22,25 @@ __copyright__ = "Copyright 2020, UnstableVortex Team"
|
||||
__module_name__ = "app"
|
||||
__version__text__ = "1"
|
||||
|
||||
if SENTRY_DSN:
|
||||
# The Flask application is not loaded yet, so we are accessing directly to the configuration values
|
||||
if Config.SENTRY_DSN:
|
||||
sentry_sdk.init(
|
||||
dsn=SENTRY_DSN,
|
||||
dsn=Config.SENTRY_DSN,
|
||||
integrations=[FlaskIntegration(), SqlalchemyIntegration()],
|
||||
traces_sample_rate=1.0,
|
||||
send_default_pii=True,
|
||||
release=RELEASE_ID,
|
||||
environment=RELEASEMODE,
|
||||
release=Config.RELEASE_ID,
|
||||
environment=Config.RELEASEMODE,
|
||||
_experiments={"auto_enabling_integrations": True}
|
||||
)
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_URI
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||
app.config['SECRET_KEY'] = SECRET_KEY
|
||||
app.config['SECURITY_REGISTERABLE'] = True
|
||||
app.config.from_object(Config)
|
||||
|
||||
health = HealthCheck()
|
||||
db.init_app(app)
|
||||
security.init_app(app, user_datastore)
|
||||
CORS(app, origins=ALLOWED_ORIGINS)
|
||||
|
||||
formatter = logging.Formatter(
|
||||
fmt="%(asctime)s - %(levelname)s - %(module)s - %(message)s"
|
||||
)
|
||||
|
||||
handler = logging.StreamHandler()
|
||||
handler.setFormatter(formatter)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger.addHandler(handler)
|
||||
CORS(app)
|
||||
|
||||
for view in [ItemView, ProfileView, UploadView, IndexView]:
|
||||
view.register(app, trailing_slash=False)
|
||||
@@ -65,10 +52,3 @@ app.add_url_rule("/healthz", "healthcheck", view_func=lambda: health.run())
|
||||
@app.before_first_request
|
||||
def init_db():
|
||||
db.create_all()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(
|
||||
debug=bool(DEBUG),
|
||||
port=int(PORT),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user