File size: 1,103 Bytes
15d97c1
dd2f10e
2e81e75
 
 
 
 
 
 
 
 
 
 
 
 
 
15d97c1
 
 
 
2e81e75
dd2f10e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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)