Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 404 on leaflet.py example #741

Closed
Galeras14 opened this issue Dec 16, 2023 · 9 comments · Fixed by #742
Closed

Error 404 on leaflet.py example #741

Galeras14 opened this issue Dec 16, 2023 · 9 comments · Fixed by #742

Comments

@Galeras14
Copy link

Hi
I created a web-app based on the leaflet.py example. It has worked fine for several years but after a few month since I did not use (Jan 2023), I get a "urllib.error.HTTPError: HTTP Error 404: Not Found".

So, I got back to the leaflet.py code from flexx readthedocs and test it as is --> the example return the same error.

What has change since the beginning of the year that makes this example to stop working ?

Thanks for any help,

@almarklein
Copy link
Member

I can reproduce that it does not work. The first exception is when the script tries to obtain https://cdnjs.cloudflare.com/ajax/libs/leaflet//1.0.3/images/marker-icon.png. However, it works fine when I copy-paste that link in the browser. Same for https://cdnjs.cloudflare.com/ajax/libs/leaflet//1.0.3/leaflet.js when I comment the lines that downloads the icons.

So it may be related to the user agent - perhaps leaflet is trying to prevent non-browsers from using the API

@jrversteegh
Copy link
Contributor

It looks like it needs an "Accept-Encoding" header.

wget https://cdnjs.cloudflare.com/ajax/libs/leaflet//1.0.3/images/marker-icon.png

doesn't work, but

wget --header='Accept-Encoding: gzip, deflate, br' https://cdnjs.cloudflare.com/ajax/libs/leaflet//1.0.3/images/marker-icon.png

does.

@almarklein almarklein mentioned this issue Dec 20, 2023
@almarklein
Copy link
Member

Thanks @jrversteegh, that explains it, and I manage to get the example working again in #742.

@Galeras14 Could you please check whether #742 fixes it for you to?

@Galeras14
Copy link
Author

Hi, thanks a lot for your help. However I'm still having trouble.
I get this error message from _get data function:

assert res.ok, f"{res.status_code}: {res.reason}"
AssertionError: 404: Not Found

In addition, I'm now having a warning message:

/Users/admin/PycharmProjects/Genealogie/env/lib/python3.7/site-packages/urllib3/init.py:38: NotOpenSSLWarning: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: urllib3/urllib3#3020
exceptions.NotOpenSSLWarning,

Not sure if it is Mac environment or if it is because I'm using Python 3.8.

@almarklein
Copy link
Member

Is that the system Python 3.8? Have you tried upgrading to the latest urllib3 using e.g. pip install -U urllib3?

@Galeras14
Copy link
Author

Yes, I'm in the latest version of urllib3, 2.0.7

@Galeras14
Copy link
Author

I've kind of solve the issue of urllib3 following #3020 issue on urllib3.
Still, the leaflet.py example give me this error, even we the suggested modifications:

Traceback (most recent call last):
File "/Users/admin/PycharmProjects/Genealogie/sample/ui/essai.py", line 82, in
flx.assets.add_shared_data(icon, _get_data('images/%s' % icon))
File "/Users/admin/PycharmProjects/Genealogie/sample/ui/essai.py", line 53, in _get_data
assert res.ok, f"{res.status_code}: {res.reason}"
AssertionError: 404: Not Found

@almarklein
Copy link
Member

almarklein commented Jan 2, 2024

Mmm. It's pretty annoying that leaflet produces a 404, and not a more meaningful error code. This way there is no way to see whether the problem is the header or your wifi being down 😕

I tried #742 and I got the same error. It looks like I was trying out some stuff and pushed the wrong version. I updated that PR to the version that works for me too. Sorry for that!

edited: I initially linked to the wrong pr above because of a typo, which I now fixed

@Galeras14
Copy link
Author

With your modification, the example works for me and my app works again.
Thanks a lot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants