backend: add partial support for viewing media

This commit is contained in:
Lucas 2023-02-19 20:22:29 +00:00
parent f63398e54f
commit b09a5e7fe1
4 changed files with 69 additions and 3 deletions

View file

@ -129,10 +129,26 @@ get "/tag/:tag_id_or_name" => sub {
};
};
get "/view/:media_id" => sub {
my $media_id = route_parameters->get("media_id");
my $res = api_get("/media/$media_id");
send_error("API error", 500) if !$res->{success};
my $data = decode_json($res->{content});
template "media" => {
no_title => 1,
title => $data->{id},
image_src => "$POORBOORU_API/download/" . $data->{id},
media_id => $data->{id},
media_filename => $data->{filename},
media_size => $data->{size},
media_tags => [],
};
};
get "/random" => sub {
};
get "/view/:media_id" => sub {
};
true;