Using files in Pyscript

122 views Asked by At

I need to use some files in my Pyscript algorithm, and I know Pyscript can´t access local files because of a security issue. But my question is, can I somehow upload those files to a virtual file system, because otherwise I'm going to be unable to run my script. When using the open() function, I'm getting an error where the file isn't found.

1

There are 1 answers

4
Jeff Glass On

If you have the files available "to the network" (either on a web server, or served locally with something like python3 -m http.serve or another simple dev server), you can uses the [files] key in py-config to load those files into the virtual filesystem.

The older [[fetch]] key is also available, but it's a little error-prone due to its complexity and options, so [files] is currently the recommended way forward.