Skip to content

Commit

Permalink
Endpoint to remove visits.csv
Browse files Browse the repository at this point in the history
  • Loading branch information
vladsavelyev committed Feb 22, 2024
1 parent 5cfcf2f commit 3d00858
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,22 @@ async def update_downloads_endpoint(background_tasks: BackgroundTasks):
msg = f"Failed to update the download stats: {e}"
raise HTTPException(status_code=http.HTTPStatus.INTERNAL_SERVER_ERROR, detail=msg)

@app.get("/remove_visits_csv")
async def remove_visits_csv():
try:
if CSV_FILE_PATH.exists():
CSV_FILE_PATH.unlink()
msg = f"Removed {CSV_FILE_PATH}"
logger.info(msg)
return PlainTextResponse(content=msg)
else:
msg = f"File {CSV_FILE_PATH} doesn't exist"
logger.info(msg)
return PlainTextResponse(content=msg)
except Exception as e:
msg = f"Failed to remove {CSV_FILE_PATH}: {e}"
raise HTTPException(status_code=http.HTTPStatus.INTERNAL_SERVER_ERROR, detail=msg)


@app.get("/version.php", response_class=PlainTextResponse)
async def version_legacy(background_tasks: BackgroundTasks, v: str | None = None):
Expand Down

0 comments on commit 3d00858

Please sign in to comment.