forked from AdaGold/task-list-api
-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy path__init__.py
42 lines (30 loc) · 1.03 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
import os
from dotenv import load_dotenv
db = SQLAlchemy()
migrate = Migrate()
load_dotenv()
def create_app(test_config=None):
app = Flask(__name__)
# app.config["SLACK_TOKEN"] = os.environ.get("SLACK_API_KEY")
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
if test_config is None:
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get(
"SQLALCHEMY_DATABASE_URI")
else:
app.config["TESTING"] = True
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get(
"SQLALCHEMY_TEST_DATABASE_URI")
# Import models here for Alembic setup
from app.models.task import Task
from app.models.goal import Goal
db.init_app(app)
migrate.init_app(app, db)
# Register Blueprints here
from app.routes.routes import tasks_bp
app.register_blueprint(tasks_bp)
from app.routes.goal_routes import goals_bp
app.register_blueprint(goals_bp)
return app