-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backend): follow proper Rest API spec and add responses to OpenA…
…PI spec Signed-off-by: Jordan Shatford <jordanshatford@live.com>
- Loading branch information
1 parent
acadbaa
commit f130ecb
Showing
4 changed files
with
85 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
from fastapi import APIRouter | ||
from fastapi import HTTPException | ||
from fastapi import status | ||
from utils.models import Video | ||
from utils.youtube import search_youtube | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get('/search', tags=['search']) | ||
@router.get( | ||
'/search', tags=['search'], responses={ | ||
status.HTTP_404_NOT_FOUND: { | ||
'description': 'No results for search', | ||
}, | ||
}, | ||
) | ||
def get_search(term: str, results: int = 12) -> list[Video]: | ||
return search_youtube(term, results) | ||
videos = search_youtube(term, results) | ||
if len(videos) == 0: | ||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND) | ||
else: | ||
return videos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters