Skip to content

Commit

Permalink
handle file not found
Browse files Browse the repository at this point in the history
  • Loading branch information
anish-work committed Aug 1, 2024
1 parent b2b650b commit a353d3d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions static_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def serve(page_slug: str, file_path: str):
blob_path = f"{WEBSITE_FOLDER_PATH}/{extract_file_name(file_path)}"

if not (blob_path.endswith(".html")):
blob = bucket.get_blob(blob_path)
if not blob or not blob.exists():
return None # 404
# redirect every path that doesn't end with .html
return dict(
redirectUrl=f"https://storage.googleapis.com/{settings.GS_BUCKET_NAME}/{blob_path}"
Expand Down

0 comments on commit a353d3d

Please sign in to comment.