why would you want to run python in the browser? Anyone can ELI5?
Python HTTP library 'urllib3' now works in the browser
21–30 of 35 posts
Re: Python HTTP library 'urllib3' now works in the browser
#22Earlier quoted context omitted.
Browsers limit the ability for these platforms to use raw sockets, there simply is no API for it. The best that can be done /today/ is to use WebSockets, which are not the same thing and can't be used for HTTP requests without the server expecting a WebSocket connection: https://github.com/emscripten-core/emscripten/issues/5196#is...
Sure, sorry if it wasn't clear from my question, it wasn't specifically about urllib3, but I meant if there are plans that browsers will make such an API available or if this is something that will never become real.
Re: Python HTTP library 'urllib3' now works in the browser
#23Earlier quoted context omitted.
Sure, sorry if it wasn't clear from my question, it wasn't specifically about urllib3, but I meant if there are plans that browsers will make such an API available or if this is something that will never become real.
I doubt browsers would allow this, though gamedevs have wanted it for decades now. Particularly UDP.
Re: Python HTTP library 'urllib3' now works in the browser
#24Re: Python HTTP library 'urllib3' now works in the browser
#25Re: Python HTTP library 'urllib3' now works in the browser
#26why would you want to run python in the browser? Anyone can ELI5?
Same reason you'd want to run your server in node.js so it matches your front end code ( and you can reuse code on the front end and backend). Pyscript lets us have the same programming language in the front end and the backend, and access to all of our internal packages on the front end.
A lot of vfx software is written in QT, so at a previous company I actually made a wrapper around a subset of the QT interface and widgets, and replicated it in Pyscript, so we could write an app once and run it from inside vfx applications, or run it in the browser with no additional coding. It wasn't perfect, but it worked and made things simpler
Re: Python HTTP library 'urllib3' now works in the browser
#27Incredible! Two years ago I was experimenting in porting some code at the company I was at to python in the browser (instead of QT desktop apps) and this was the biggest thing I had to work around! I had to manually monkey patch or proxy a few libraries to make them work, but I'll have to test out this update and see if everything magically works
Note that we found an issue w/ emitting an InsecureRequestWarning by default. The request is perfectly secure, it's just we aren't telling the ConnectionPool that information (see: https://github.com/urllib3/urllib3/issues/3331)
Re: Python HTTP library 'urllib3' now works in the browser
#28Earlier quoted context omitted.
isn't the udp problem fixed with http3 unreliable webtransport?
Is it? That would be cool. Under the hood is it actual udp?
Re: Python HTTP library 'urllib3' now works in the browser
#29Earlier quoted context omitted.
Am I misunderstanding this? You need JS to load the WASM module anyways, what does "requiring JS" means here?
It means that urllib3 (python code) isn't actually making the http request (it's not making the tcp connection, tls auth, writing the request, or serializing the request headers ...) It may be better to describe this as a "shim". Any python code that depended on urllib3 is now transparently shimmed in browser context to use the fetch-api instead. Which is useful.
To do something like that then you’re going to need a different environment with a different set of security guarantees and expectations, more like a shell where the user is responsible for vouching for the code’s trustworthiness.
Re: Python HTTP library 'urllib3' now works in the browser
#30Earlier quoted context omitted.
isn't the udp problem fixed with http3 unreliable webtransport?
Is it? That would be cool. Under the hood is it actual udp?
https://developer.chrome.com/docs/capabilities/web-apis/webt...