diff --git a/program_service/app.py b/program_service/app.py index 3153f37..50ec040 100644 --- a/program_service/app.py +++ b/program_service/app.py @@ -4,7 +4,7 @@ import sentry_sdk from sentry_sdk.integrations.flask import FlaskIntegration from flask import Flask -from utils import register_all_error_handlers +from utils import register_all_error_handlers, mongo # import views from views import ProgramView @@ -25,6 +25,8 @@ app = Flask(__name__) app.config.from_object(Config) register_all_error_handlers(app) +# init mongodb +mongo.init_app(app) # register views for view in [ProgramView]: diff --git a/program_service/config.py b/program_service/config.py index 532830c..28cb9ac 100644 --- a/program_service/config.py +++ b/program_service/config.py @@ -7,6 +7,7 @@ Configuration class Config: + MONGO_URI = os.environ["MONGO_URI"] SECRET_KEY = os.environ.get("SECRET_KEY", os.urandom(12)) CORS_ORIGINS = os.environ.get("ALLOWED_ORIGINS", "*") diff --git a/program_service/utils/__init__.py b/program_service/utils/__init__.py index a1e0203..3225afb 100644 --- a/program_service/utils/__init__.py +++ b/program_service/utils/__init__.py @@ -1,3 +1,4 @@ #!/usr/bin/env python3 from .require_decorators import json_required -from .error_handlers import register_all_error_handlers \ No newline at end of file +from .error_handlers import register_all_error_handlers +from .db import mongo diff --git a/program_service/utils/db.py b/program_service/utils/db.py new file mode 100644 index 0000000..5866800 --- /dev/null +++ b/program_service/utils/db.py @@ -0,0 +1,3 @@ +from flask_pymongo import PyMongo + +mongo = PyMongo() diff --git a/requirements.txt b/requirements.txt index d0408c6..142d75a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ marshmallow Flask-Classful sentry-sdk +Flask-PyMongo~=2.3.0 \ No newline at end of file