instance1 / app.py
ChandimaPrabath's picture
init
dd2f10e
raw
history blame
1.1 kB
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from Instance import Instance
from api import LoadBalancerAPI
import os
# Constants and Configuration
CACHE_DIR = os.getenv("CACHE_DIR")
INDEX_FILE = os.getenv("INDEX_FILE")
TOKEN = os.getenv("TOKEN")
REPO = os.getenv("REPO")
ID = os.getenv("ID")
URL = os.getenv("URL")
LOAD_BALANCER_URL = os.getenv("LOAD_BALANCER_URL")
load_balancer_api = LoadBalancerAPI(base_url=LOAD_BALANCER_URL)
instance = Instance(id=ID, url=URL, cache_dir=CACHE_DIR, index_file=INDEX_FILE, token=TOKEN, repo=REPO, load_balancer_api=load_balancer_api)
app = FastAPI()
@app.get("/")
async def index():
return instance.version
@app.get("/api/get/report")
async def get_report():
report=instance.compile_report()
return JSONResponse(report)
@app.get('/api/get/tv/store')
async def get_tv_store_api():
"""Endpoint to get the TV store JSON."""
return JSONResponse(instance.TV_STORE)
@app.get('/api/get/film/store')
async def get_film_store_api():
"""Endpoint to get the TV store JSON."""
return JSONResponse(instance.FILM_STORE)