brownplt / pyret-lang

The Pyret language.
Other
1.07k stars 110 forks source link

Unable to load image. #1224

Closed Kaykwanu closed 6 years ago

Kaykwanu commented 6 years ago

Hi, I am unable to load the AIRPLANE image in CHAPTER 11 (PAPL) using:

AIRPLANE-URL =
  "http://world.cs.brown.edu/1/clipart/airplane-small.png"
AIRPLANE = I.image-url(AIRPLANE-URL)

Error Message reads:

unable to load index.html/downloadImg?http://world.cs.brown.edu/1/clipart/airplane-small.png: undefined

What am I doing wrong? Find error image attached.

Also, shouldn't I be able to load the image locally from my computer, while my browser and pyret is offline? If yes, please how. Thanks.

load airplane error

sorawee commented 6 years ago

It works fine for me. Can you access http://world.cs.brown.edu/1/clipart/airplane-small.png in a web browser?

screenshot from 2017-10-14 23-59-50

(The error message is not nice to users, but that's a separate issue)

Kaykwanu commented 6 years ago

Yes. I can access http://world.cs.brown.edu/1/clipart/airplane-small.png in my chrome, but the error persists. Also I wanted to know if I could use a locally stored image in my computer. On Sun, Oct 15, 2017 at 5:02 AM sorawee notifications@github.com wrote:

It works fine for me. Can you access http://world.cs.brown.edu/1/clipart/airplane-small.png in a web browser?

[image: screenshot from 2017-10-14 23-59-50] https://user-images.githubusercontent.com/9099577/31581519-ed64cc7e-b13b-11e7-9c84-5e2bd22e00a5.png

(The error message is not nice to users, but that's a separate issue)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/brownplt/pyret-lang/issues/1224#issuecomment-336684802, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDxe8KoCp0QwHtVGmjssEtkDstexPcSks5ssYPGgaJpZM4P5nSB .

sorawee commented 6 years ago

@jpolitz I got the error unable to load https://code.pyret.org/downloadImg?http://world.cs.brown.edu/1/clipart/airplane-small.png2: undefined when I tried to use an invalid URL intentionally. So it seems APP_BASE_URL in the above case is wrong. It's supposed to be https://code.pyret.org/editor but from the error message it appears to be index.html. Do you know anything about this?

@Kaykwanu Sorry, I didn't see the other question. I myself don't have a good answer. The best way that I know is to simply upload your images to Google Drive and share these images publicly. Then, for a shareable link like https://drive.google.com/open?id=0Bxr4FfLa3goORFZGckU1SEFkaWM, use https://docs.google.com/uc?id=0Bxr4FfLa3goORFZGckU1SEFkaWM as the link in your program instead (that is, use https://docs.google.com/uc?id=<your-shared-file-id>).

Can I ask what OS and browser are you using? If you can use web browser console, can you type APP_BASE_URL and see what it outputs?

blerner commented 6 years ago

Websites in a browser are not permitted to load local files via URL -- just think how huge of a security nightmare that would be! -- so we can't support that for Pyret even if we wanted to. (There are some workarounds, possibly, but they're pretty lousy and wouldn't work well in general.)

Kaykwanu commented 6 years ago

I get it now. Thanks Ben.

On Sun, Oct 15, 2017 at 8:53 PM, Ben Lerner notifications@github.com wrote:

Websites in a browser are not permitted to load local files via URL -- just think how huge of a security nightmare that would be! -- so we can't support that for Pyret even if we wanted to. (There are some workarounds, possibly, but they're pretty lousy and wouldn't work well in general.)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/brownplt/pyret-lang/issues/1224#issuecomment-336736846, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDxe6txLQFlm6uI8-HX_fodgi0WQQG4ks5ssmKzgaJpZM4P5nSB .

Kaykwanu commented 6 years ago

Sorawee,

I like to run pyret completely offline, and so I downloaded the editor and documents offline using HTTrack (although the editor fails offline when I clear my cache or when my browser crashes, otherwise it works fine).

I reckoned that since I would be requesting the AIRPLANE image online, I might as well connect to the internet and get on with it.

The mistake I was probably making was connecting online with the HTTrack(i.e oflline) version of my pyret editor, thus the error message. I noticed this using the web console lead you gave: Inputting APP_BASE_URL in the browser console while using the HTTrack-offline version(even while connected to the internet), I get "index.html", but when I am properly online i.e using the proper url - https://code.pyret.org/editor, I get "https://code.pyret.org https://code.pyret.org".

I really like the idea of being able to run pyret offline and that the setup-time to get coding is very little, thus the questions about loading the image locally from my computer, but I think I am clear now. Thanks so much for the prompt responses.

On Sun, Oct 15, 2017 at 8:24 PM, sorawee notifications@github.com wrote:

@jpolitz https://github.com/jpolitz I got the error unable to load https://code.pyret.org/downloadImg?http://world.cs. brown.edu/1/clipart/airplane-small.png2: undefined when I tried to use an invalid URL intentionally. So it seems APP_BASE_URL in the above case is wrong. It's supposed to be https://code.pyret.org/editor but from the error message it appears to be index.html. Do you know anything about this?

@Kaykwanu https://github.com/kaykwanu Sorry, I didn't see the other question. I myself don't have a good answer. The best way that I know is to simply upload your images to Google Drive and share these images publicly. Then, for a shareable link like https://drive.google.com/open?id= 0Bxr4FfLa3goORFZGckU1SEFkaWM, use https://docs.google.com/uc?id= 0Bxr4FfLa3goORFZGckU1SEFkaWM as the link in your program instead (that is, use https://docs.google.com/uc?id=).

Can I ask what OS and browser are you using? If you can use web browser console, can you type APP_BASE_URL and see what it outputs?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/brownplt/pyret-lang/issues/1224#issuecomment-336734859, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDxe-I63qPOBTOqHfv3NTwpOXBKoQEhks5sslvbgaJpZM4P5nSB .

shriram commented 6 years ago

Thanks for ​the explanation. This kind of user feedback is immensely valuable to us!

Kaykwanu commented 6 years ago

My pleasure. Pyret has also been immensely valuable to me. Thanks guys.

On Sun, Oct 15, 2017 at 10:23 PM, Shriram Krishnamurthi < notifications@github.com> wrote:

Thanks for ​the explanation. This kind of user feedback is immensely valuable to us!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/brownplt/pyret-lang/issues/1224#issuecomment-336742655, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDxe4kLPd47kibWPqO8Rm9mi3dreTHPks5ssnfHgaJpZM4P5nSB .

shriram commented 6 years ago

Thank you! Are you doing this as part of a course somewhere?

Kaykwanu commented 6 years ago

No, not at all.

I live in Nigeria, and I just wanted to learn programming because I felt it would be an important tool for life and also impart my general thinking remarkably.

At the time I was using freecodecamp and it wasn't so bad - but it had felt rote to me, because I wasn't really appreciating why I was doing whatever I was being asked to do (and it didn't feel thorough too).

Then I came across an article on medium that talked about python, but advised total newbies to consider PYRET. So, I check out pyret. I just wanted a proper introduction to programming. I am a total sucker for fundamentals, so the whole pyret and its education philosophy resonated with me. Thanks guys.

P.S. I decided to follow pyret on twitter, hoping to catch whatever new things comes up...and the pyret websites suggests that the google group would be the channel for enquiries or complaints, but so far its the github that has served me well - very helpful and prompt.

On Sun, Oct 15, 2017 at 11:30 PM, Shriram Krishnamurthi < notifications@github.com> wrote:

Thank you! Are you doing this as part of a course somewhere?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/brownplt/pyret-lang/issues/1224#issuecomment-336746542, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDxe2bgxgNt-FUo2YtzGwcaDNqOHLC9ks5ssoedgaJpZM4P5nSB .

shriram commented 6 years ago

That's awesome. Thanks for sharing with us. Hope to see more great stuff from you!

fswalker commented 6 years ago

Hello folks! I see the same error: unable to load https://code.pyret.org/downloadImg?https://world.cs.brown.edu/1/clipart/airplane-small.png: undefined

Any ideas why is this happening and how can I fix this? Thank you!

jpolitz commented 6 years ago

Thanks for pointing this out. It looks like the code.pyret.org image proxy is being super-stringent about https certificates here – it works in browser but gives an error through our proxy. I'll look into a workaround (I see a few possible technical solutions).

johnbburk commented 6 years ago

I'm getting this same error, even when I try to change to an image shared on Google drive as described here. Would love to know any workarounds...

jpolitz commented 6 years ago

Update – I've simply re-hosted the image elsewhere. The documentation now points to

https://www.pyret.org/docs/latest/airplane-small.png

https://www.pyret.org/docs/latest/Tutorial__A_Flight_Lander_Game.html

This works fine without doing zany https workarounds. Something is up with that other server's certificate. So this image should work instead.

Sorry for the silly delay in getting this fixed; re-hosting is an obvious-in-hindsight way to handle this and make the docs nice and clean.

Marking fixed, because I don't find the underlying http issue compelling (we'd have to compromise security of requests to get around this).

@occam98 the Drive issue is surprising, that should always be an OK workaround. It probably makes sense to make a new issue for that. With that in mind –

Would you mind trying to load this program and tell me if the image loads for you?

https://code.pyret.org/editor#share=1IzwrANcZOwnmk8bKjpu1vpw6cbHKasxR&v=7865ced

The relevant code is

include image
image-url("https://code.pyret.org/shared-image-contents?sharedImageId=16f50weRHy3fEOQCV2ig7mSJY3TYohkWC")

If you are OK sharing your code, I'd be happy to have a look at a link you generate from "Publish" to help debug.

johnbburk commented 6 years ago

-john On Aug 29, 2018, 12:02 AM +0200, Joe Politz notifications@github.com, wrote:

Update – I've simply re-hosted the image elsewhere. The documentation now points to https://www.pyret.org/docs/latest/airplane-small.png https://www.pyret.org/docs/latest/Tutorial__A_Flight_Lander_Game.html

This now works perfectly for me.

This works fine without doing zany https workarounds. Something is up with that other server's certificate. So this image should work instead. Sorry for the silly delay in getting this fixed; re-hosting is an obvious-in-hindsight way to handle this and make the docs nice and clean. Marking fixed, because I don't find the underlying http issue compelling (we'd have to compromise security of requests to get around this). @occam98 the Drive issue is surprising, that should always be an OK workaround. It probably makes sense to make a new issue for that. With that in mind – Would you mind trying to load this program and tell me if the image loads for you? https://code.pyret.org/editor#share=1IzwrANcZOwnmk8bKjpu1vpw6cbHKasxR&v=7865ced The relevant code is include image image-url("https://code.pyret.org/shared-image-contents?sharedImageId=16f50weRHy3fEOQCV2ig7mSJY3TYohkWC") If you are OK sharing your code, I'd be happy to have a look at a link you generate from "Publish" to help debug. This worked fine as well.

And when I followed the instructions more carefully, I was able to get the Google hosted image working as well, so I don’t think it is actually a problem.

Thanks for all the help.

itHub, or mute the thread.