69 lines
1.9 KiB
Python
69 lines
1.9 KiB
Python
from tidal_dl_ng.config import Settings, Tidal
|
|
from tidal_dl_ng.constants import CTX_TIDAL, MediaType
|
|
from tidal_dl_ng.download import Download
|
|
from tidal_dl_ng.helper.path import get_format_template, path_file_settings
|
|
from tidal_dl_ng.helper.tidal import (
|
|
all_artist_album_ids,
|
|
get_tidal_media_id,
|
|
get_tidal_media_type,
|
|
instantiate_media,
|
|
)
|
|
from tidal_dl_ng.helper.wrapper import LoggerWrapped
|
|
from tidal_dl_ng.model.cfg import HelpSettings
|
|
|
|
from rich.live import Live
|
|
from rich.panel import Panel
|
|
from rich.progress import BarColumn, Console, Progress, SpinnerColumn, TextColumn
|
|
from rich.table import Table
|
|
|
|
from pathlib import Path
|
|
from typing import Annotated, Optional
|
|
from fastapi import FastAPI, HTTPException, Depends, Request, Form
|
|
from fastapi.templating import Jinja2Templates
|
|
from fastapi.staticfiles import StaticFiles
|
|
from pydantic import BaseModel
|
|
from typing import List, Optional
|
|
import uvicorn
|
|
|
|
# Initialize FastAPI app
|
|
app = FastAPI(
|
|
title="FastAPI Template",
|
|
description="A simple FastAPI template with basic CRUD operations",
|
|
version="1.0.0",
|
|
)
|
|
|
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|
|
|
|
# Initialize Jinja2 templates
|
|
templates = Jinja2Templates(directory="templates")
|
|
|
|
|
|
# Main Landing Page
|
|
@app.get("/")
|
|
async def main(request: Request):
|
|
return templates.TemplateResponse(
|
|
"pages/index.html", {"request": request, "title": "Home Page"}
|
|
)
|
|
|
|
|
|
# Health check endpoint
|
|
@app.get("/health")
|
|
async def health_check():
|
|
return {"status": "healthy"}
|
|
|
|
|
|
@app.post("/search")
|
|
async def search(category: str = Form(...), query: str = Form(...)):
|
|
print(category)
|
|
print(query)
|
|
|
|
|
|
@app.get("/login")
|
|
async def login() -> bool:
|
|
print("Let us check, if you are already logged in... ", end="")
|
|
return {}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
|