FooSoft / anki-connect

Anki plugin to expose a remote API for creating flash cards.
https://foosoft.net/projects/anki-connect/
Other
1.92k stars 218 forks source link

Updated Python example code to use 127.0.0.1 instead of localhost #391

Closed Aquafina-water-bottle closed 1 year ago

Aquafina-water-bottle commented 1 year ago

Apparently, urllib.request.urlopen takes a very long time to load when using localhost instead of 127.0.0.1 on Windows. This PR simply changes localhost to 127.0.0.1 in the sample code.

I initially thought of doing something like:

import platform
url = "127.0.0.1" if platform.system() == "Windows" else "localhost"

However, given that the Javascript example is using 127.0.0.1 already, I figured it is fine to replace localhost entirely.

Related issue & more reading material: #389

FooSoft commented 1 year ago

How bizarre! Anyways, thanks for the fix!