Forums

Writing files

Hello! I have an app that takes a file input, analyzes it, then creates and writes an output file to a directory. Then I have a link on a webpage to download the output file. It works fine on my machine but not as expected when I deploy to pythonanywhere. I was thinking of having the app write the file to the static folder and then direct the download link to that folder, but that's not working and I'm probably doing something wrong. Please help. Thanks!

Have a look at http://help.pythonanywhere.com/pages/StaticFiles/ and http://help.pythonanywhere.com/pages/DebuggingStaticFiles/

That was helpful glenn! Got it working now, thanks!

Hi I am having an issue I cant write files to my static > images folder. I get a 500 Internal Server Error. My error log is https://www.pythonanywhere.com/user/Jahnvi371/files/var/log/jahnvi371.pythonanywhere.com.error.log.

Make sure that the path you're trying to write to exists and that you are paying attention to the working directory or using absolute paths: https://help.pythonanywhere.com/pages/NoSuchFileOrDirectory/

I am using an absolute path. So first, I write an image to /home/jahnvi371/fyp/static/images using /home/jahnvi371/fyp/static/images/image.png. But when I checked this /static/images folder, no files get written. But I cannot understand why these files don't get written. Can pls help with this? Thanks :)

You're using the incorrect path. The path to you home directory is /home/Jahnvi371, not home/jahnvi371

Oh I see ok thanks that works!!

Good to hear that!