示例#1
0
def get_sql_alchemy_instance() -> SQLAlchemy:
    global sql_alchemy_instance

    if not sql_alchemy_instance:
        web_app = get_web_app()
        sql_alchemy_instance = SQLAlchemy(web_app)

    return sql_alchemy_instance
示例#2
0
from src import web_app as web_app_module, configurations as config_module, endpoints
from src import aws as aws_module
from src import PodcastService, TranscribeService
from src.domain import DomainService
from src.infrascructure import CacheRepository
from src.infrascructure import create_repository
from src.rss_reader import RssReader
from src.transcribe import AWSTranscribe

web_app = web_app_module.get_web_app()
api = web_app_module.get_api()
configurations = config_module.get_config()
transcribe_client = aws_module.get_transcribe_client()
s3_client = aws_module.get_s3_client()

cache_repository = CacheRepository()
rss_reader = RssReader()
mongodb_repository = create_repository(configurations)
domain_service = DomainService()
aws_transcribe = AWSTranscribe(transcribe_client)

podcast_service = PodcastService(mongodb_repository, rss_reader,
                                 cache_repository, domain_service)
transcribe_service = TranscribeService(aws_transcribe, s3_client)

endpoints.register(podcast_service=podcast_service,
                   transcribe_service=transcribe_service)
示例#3
0
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand

import sys

from src.db_connections import get_sql_alchemy_instance
from src.web_app import get_web_app


if __name__ == '__main__':
    web_app = get_web_app()
    sql_alchemy = get_sql_alchemy_instance()

    flask_manager = Manager(web_app)

    if 'db' in sys.argv:
        migrate = Migrate(web_app, sql_alchemy)
        flask_manager.add_command('db', MigrateCommand)

    flask_manager.run()