add artists to ui
This commit is contained in:
parent
aa02cf9fa4
commit
5c8c770f96
10
database.py
10
database.py
@ -32,6 +32,16 @@ async def get_random_track(request):
|
|||||||
return track
|
return track
|
||||||
|
|
||||||
|
|
||||||
|
async def get_artists(request):
|
||||||
|
"""Returns all artists in the database."""
|
||||||
|
async with request.app.state.db_pool.acquire() as conn:
|
||||||
|
artists = await conn.fetch(
|
||||||
|
"SELECT DISTINCT albumartist FROM track ORDER BY albumartist"
|
||||||
|
)
|
||||||
|
artists = [a['albumartist'] for a in artists]
|
||||||
|
return artists
|
||||||
|
|
||||||
|
|
||||||
def convert_filepath(path):
|
def convert_filepath(path):
|
||||||
"""Convert a filepath to a URL."""
|
"""Convert a filepath to a URL."""
|
||||||
path = os.path.relpath(path, config.music_dir)
|
path = os.path.relpath(path, config.music_dir)
|
||||||
|
@ -23,7 +23,8 @@ templates = Jinja2Templates(directory="templates")
|
|||||||
|
|
||||||
@app.get("/", response_class=HTMLResponse)
|
@app.get("/", response_class=HTMLResponse)
|
||||||
async def index(request: Request):
|
async def index(request: Request):
|
||||||
context = {"request": request}
|
artists = await db.get_artists(request)
|
||||||
|
context = {'request': request, 'artists': artists}
|
||||||
return templates.TemplateResponse('index.html', context)
|
return templates.TemplateResponse('index.html', context)
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ input[type="radio"]:checked+div {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5em;
|
gap: 0.5em;
|
||||||
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.list_item:hover {
|
.list_item:hover {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user