Skip to content

Commit

Permalink
fixes, refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rlellep committed Jan 11, 2023
1 parent b8a02dc commit c309c7e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/api/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async def get_audiobook(job_id: str, session: AsyncSession = Depends(database.ge
return FileResponse(file_path, filename=f"{job_id}.zip")


@router.get('/{job_id}/epub', response_class=Union[FileResponse, str],
@router.get('/{job_id}/epub', response_class=FileResponse,
description='Get the epub of a scheduled or an ongoing job.',
responses={
404: {"model": ErrorMessage},
Expand All @@ -144,8 +144,8 @@ async def get_audiobook(job_id: str, session: AsyncSession = Depends(database.ge
async def get_epub(job_id: str, _: str = Depends(get_username),
session: AsyncSession = Depends(database.get_session)):
job_info = await database.read_job(session, job_id)
if job_info.state != State.EXPIRED:
return 'Job expired.'
if job_info.state == State.EXPIRED:
return HTTPException(404, f'Job {job_id} expired.')
if job_info.state == State.QUEUED:
await database.update_job(session, job_id, State.IN_PROGRESS)
return FileResponse(os.path.join(api_settings.storage_path, f"{job_id}.epub"), filename=f"{job_id}.epub")
Expand Down
3 changes: 1 addition & 2 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ async def health_check():
conn = await db_engine.connect()
await conn.close()
except Exception as e:
print(e)
raise HTTPException(500)
raise HTTPException(500, str(e))

return "OK"

Expand Down
2 changes: 1 addition & 1 deletion sample.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
HTTP_PORT=80
HTTP_HOST=172.19.0.1
HTTP_HOST=172.27.0.1
RABBITMQ_USER=guest
RABBITMQ_PASS=guest
MYSQL_USER=guest
Expand Down

0 comments on commit c309c7e

Please sign in to comment.