from os import environ from pathlib import Path import uvicorn from gallery.easel import build_app from gallery.painting.gismeteo.api import GismeteoApi from gallery.painting.matchtv.api import MatchTVApi from gallery.painting.openweather.api import OpenWeatherApi from gallery.painting.rp5.api import RP5WeatherApi from gallery.painting.yandextv.api import YandexTVApi from gallery.painting.yandexweather.api import YandexWeatherApi from gallery.sketch.bundle import ApiBundle from gallery.sketch.schedule.cached import CachedScheduleApi from gallery.sketch.weather.cached import CachedWeatherApi api = ApiBundle( [ CachedScheduleApi(YandexTVApi()), CachedScheduleApi(MatchTVApi()), CachedWeatherApi(GismeteoApi()), CachedWeatherApi(OpenWeatherApi()), CachedWeatherApi(YandexWeatherApi()), CachedWeatherApi(RP5WeatherApi()), ] ) app = build_app(api) def run(): uvicorn.run( "gallery.main:app", host=environ.get("GALLERY_HOST", "0.0.0.0"), port=int(environ.get("GALLERY_PORT", 8000)), log_config=str(Path(__file__).parent / "logging.yaml"), reload="DEBUG" in environ, ) if __name__ == "__main__": run()