Skip to content

Commit

Permalink
add /file_exists/ route to check if file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jojortz committed Oct 5, 2023
1 parent 6a12dff commit 07e2ef8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pykoi/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,18 @@ async def get_components(
]
)

@app.get("/file_exists/")
async def check_file_exists(
file_name: str,
user: Union[None, UserInDB] = Depends(self.get_auth_dependency()),
):
try:
file_path = f"{os.getcwd()}/{file_name}"
file_exists = os.path.exists(file_path)
return {"log": f"Check if {file_name} exists succeeded.", "file_exists": file_exists, "status": "200"}
except Exception as ex:
return {"log": f"Check if {file_name} exists failed: {ex}", "status": "500"}

def create_data_route(id: str, data_source: Any):
"""
Create data route for the application.
Expand Down

0 comments on commit 07e2ef8

Please sign in to comment.