mirror of
https://github.com/rommapp/romm.git
synced 2026-06-30 07:45:52 +00:00
Improve OpenAPI documentation by setting tags to each API router. Also, set a prefix to each router to group the endpoints by their functionality.
33 lines
939 B
Python
33 lines
939 B
Python
from config import ASSETS_BASE_PATH
|
|
from decorators.auth import protected_route
|
|
from fastapi import Request
|
|
from fastapi.responses import FileResponse
|
|
from handler.auth.constants import Scope
|
|
from utils.router import APIRouter
|
|
|
|
router = APIRouter(
|
|
prefix="/raw",
|
|
tags=["raw"],
|
|
)
|
|
|
|
|
|
@protected_route(router.head, "/assets/{path:path}", [Scope.ASSETS_READ])
|
|
def head_raw_asset(request: Request, path: str):
|
|
asset_path = f"{ASSETS_BASE_PATH}/{path}"
|
|
return FileResponse(path=asset_path, filename=path.split("/")[-1])
|
|
|
|
|
|
@protected_route(router.get, "/assets/{path:path}", [Scope.ASSETS_READ])
|
|
def get_raw_asset(request: Request, path: str):
|
|
"""Download a single asset file
|
|
|
|
Args:
|
|
request (Request): Fastapi Request object
|
|
|
|
Returns:
|
|
FileResponse: Returns a single asset file
|
|
"""
|
|
|
|
asset_path = f"{ASSETS_BASE_PATH}/{path}"
|
|
return FileResponse(path=asset_path, filename=path.split("/")[-1])
|