Can we read local file from Sagecell
Can we read local file from Sagecell? I work with SageMathCell embedded on blog.
Can we read local file from Sagecell? I work with SageMathCell embedded on blog.
No, you can not read a local file from Sagecell. Sagecell is like any webserver, imagine the security hole if an arbitrary webserver you connect to with a webbrowser could read any file on your hard disk ! If you want to let Sagecell access some file, you have to serve it publically, this works well, see the answer of your other question.
Thanks a lot...
Yes, you can:
with open("/path/filename", 'r') as fin:
print fin.read()
This is a way to read local files into a SageMath notebook on your own computer, but it won't work on SageMathCell: https://sagecell.sagemath.org/
I tried it on https://sagecell.sagemath.org/ and a reasonable output was produced for the file "/etc/hosts".
But that isn't local to YOUR computer, is it? Presumably whatever Google App Engine computer is running the cell server.
Asked: 7 years ago
Seen: 1,302 times
Last updated: Mar 05 '18
Hmm, that is a good question. I'd assume not unless you can read from the internet - some Sage functions allow URLs in them. But it wouldn't have access to your file system.
Thank you...