Forums

Making file accessible by link

Hi!

Im trying to make a file accessible to all with just using the url to the file. When im logged in, I can access https://www.pythonanywhere.com/user/USERNAME/files/home/USERNAME/FOLDER_NAME/file.txt but when i try to access it when im not logged in, its not working. Ive tried to chage the permissions to the file, but to no luck. Help is much appreciated!

Here are some options...

Share the File via the GUI: Open the file in the editor and slick "share" in the toolbar. You should then be able to share the file with a public link. You will not be able to edit the file, but it can be copied to another PA account.

Access via Web App: You can create a static file mapping to the folder and share that link.

Is this what you were trying to do? If you are trying to share for editing, I don't believe there is this feature natively in PA right now other than sharing the file, letting them use the feature to copy it to their account and then sharing back a new version.

Im planning to share the link for read-only. The link needs to be static as the folder will have different files with different auto-generated names (from a variable).

I believe the way to aproach this is by the static file mapping as the folder that is made there is publicly accessible by default?

If you are trying to do online file sharing, it would be best to write a small app in something like Flask. I did something like this for my personal website

@app.route('/<path:path>'):
def index(path)
     # map the directory
     # render into a template to show both files and folders
     return render_template('file_folder_page.html',files=files)

The easiest way to do it is by Static files mappings

Thank you all!

For anyone using Django, you can manually add files to your existing media folder, and access them via their path: me.pythonanywhere.com/media/file.txt (depends on your medias files config also)