PIbd-32_Kashin_M.I_API_Cour.../router_class.py

22 lines
648 B
Python

from fastapi import APIRouter
from typing import List
router = APIRouter(
prefix="/class",
tags=["Class"],
)
@router.get("/negative")
async def get_class_names() -> List[str]:
with open(".//neural_network/classification/class_names_negative.txt", "r", encoding="utf-8") as file:
class_names = [line.strip() for line in file.readlines()]
return class_names
@router.get("/positive")
async def get_class_names() -> List[str]:
with open(".//neural_network/classification/class_names_positive.txt", "r", encoding="utf-8") as file:
class_names = [line.strip() for line in file.readlines()]
return class_names