Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Hotfix/disk renderer handle http 301 302 #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion django_medusa/renderers/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def _disk_render_path(args):
outpath = os.path.join(DEPLOY_DIR, realpath)

resp = client.get(path)
if resp.status_code == 301 or resp.status_code == 302:
print('%s - redirect - skipping...' % path)
return None
if resp.status_code != 200:
raise Exception
if needs_ext:
Expand All @@ -53,7 +56,11 @@ def _disk_render_path(args):
outpath += "index.html"
print(outpath)
with open(outpath, 'wb') as f:
f.write(resp.content)
if resp.streaming:
for chunk in resp.streaming_content:
f.write(chunk)
else:
f.write(resp.content)


class DiskStaticSiteRenderer(BaseStaticSiteRenderer):
Expand Down