INNER CODE UNIT · Python
delete_file
iamgreggarcia/codesherpa · localserver/main.py:152
async def delete_file(fileName: str):
"""
Delete a file from the static/uploads directory.
Args:
fileName (str): The name of the file to delete.
Returns:
dict: The result of the file deletion process.
"""
try:
file_location = f"static/uploads/{fileName}"
os.remove(file_location)
logger.info(f"File deleted: {fileName}")
return {"result": "File deleted successfully"}
except Exception as e: