1

I have this simple function in my Flask app.

@app.route('/download')
@login_required
def download():
    url="some_random_video_url_here"
    re = requests.get(url)
    with open("download/hello.mp4", 'wb') as file: #save hello.mp4 to download folder
        file.write(re.content)
        file.close()
flash("done downloading.")
return render_template('download.html')

When I run the app locally, the download function just run fine. But when I deploy the code to Heroku and access the url, I get 500 Internal Server Error

I think it has something to do with file system on Heroku but I don't know how to make this work. So how?

Zip
  • 5,372
  • 9
  • 28
  • 39
  • Does the download/ directory exist? Note that the Heroku filesystem is temporary (https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem). – elithrar Jul 09 '15 at 22:34
  • Can you post the Heroku log? https://devcenter.heroku.com/articles/logging#view-logs – fasouto Jul 09 '15 at 22:34
  • @elithrar yes, I included download folder in git push. – Zip Jul 09 '15 at 22:40
  • @fasouto 2015-07-09T22:27:36.092922+00:00 heroku[router]: at=info method=POST path="/login?next=/download" host=discover-flask-again.herokuapp.com request_id=e270875b-ddc7-47d8-ab04-2cadd7c31797 fwd="85.165.229.223" dyno=web.1 connect=0ms service=29ms status=302 bytes=538 – Zip Jul 09 '15 at 22:42
  • Can you wrap your `open` call in a try/except block (see http://stackoverflow.com/a/8380019/556573) - otherwise there is no way to inspect what error (if any) is being returned. – elithrar Jul 12 '15 at 06:33

0 Answers0