Skip to content

Commit

Permalink
Update configuration in __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
apradoada committed Dec 6, 2024
1 parent 2f9e150 commit 3846a17
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import os
from flask import Flask
from .routes.pet_routes import bp
from .routes.pet_routes import bp as pets_bp
from .db import db, migrate
from .models import pet

def create_app(test_config=None):
def create_app(config=None):
# __name__ stores the name of the module we're in
app = Flask(__name__)

if not test_config:
db_to_use = os.environ.get("SQLALCHEMY_DATABASE_URI")
else:
db_to_use = os.environ.get("SQLALCHEMY_TEST_DATABASE_URI")


app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_DATABASE_URI'] = db_to_use
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('SQLALCHEMY_DATABASE_URI')
if config:
app.config.update(config)

db.init_app(app)
migrate.init_app(app, db)

app.register_blueprint(bp)
app.register_blueprint(pets_bp)

return app

0 comments on commit 3846a17

Please sign in to comment.