For folks interested in seeing a usecase, I have a panel dashboard of Dallas crime statistics at:<p><a href="https://crimede-coder.com/graphs/Dallas_Dashboard" rel="nofollow">https://crimede-coder.com/graphs/Dallas_Dashboard</a><p>Startup takes around a minute (which includes installing various python libraries + loading an external 5mb dataset). But once up and running it is quite responsive. (And works fine on my iphone.)<p>Many businesses I work with use Tableau free versions, and just manually update the data (since the free doesn't allow direct connections to a datastore). This is a free alternative (I use github actions to build a zipped up csv file that is pulled into the environment).
The homepage left me confused, and also after reading the documentation, I'm not sure what this is.<p>I tinkered a bit to try it myself.<p>Turns out you can throw this into your website and it will display "Hello World":<p><pre><code> <script type="module" src="https://pyscript.net/releases/2024.8.2/core.js"></script>
<script type="py">
import js
js.document.querySelector("body").innerText = "Hello World"
</script>
</code></pre>
So it seems to be a script that looks for scripts of type "py" and transpiles them from Python to JavaScript via Pyodide?<p>On the other hand, the demo on the homepage is a repl. And the title says "platform". So I'm still confused.
How is this different from pyodide[0]?<p>[0]: <a href="https://pyodide.org/en/stable/" rel="nofollow">https://pyodide.org/en/stable/</a>
I recently went down the rabbit hole of using PyScript for running a Python CLI app in the browser.<p>It felt hacky the whole time, especially when dependencies were involved. I had to create wrapper classes to work around Pydantic 2.x not being available to use. I tried to put all logic into the Python files but found some things missing that I had to put in JavaScript.<p>I think it could be good in use cases where you want some simple UI with custom UI logic on top of your Python code but maybe Streamlit or Gradio could be more suitable.<p>GitHub repo: <a href="https://github.com/data-catering/data-contract-playground">https://github.com/data-catering/data-contract-playground</a><p>Website: <a href="https://data-catering.github.io/data-contract-playground/" rel="nofollow">https://data-catering.github.io/data-contract-playground/</a>
I can't find any real world use case there. If you want to run ML Models you can build them to Onnx <a href="https://onnxruntime.ai/docs/tutorials/web/" rel="nofollow">https://onnxruntime.ai/docs/tutorials/web/</a> . Will this efficient to build browser based app in place of JS/TS ?
What i would like, if i could write scripts in firefox, which act the browser, like doing the evaluation at any stage i like. At GET the page, after ALL GETs. After javascript evaluation or before.<p>Is there something which can do this? and with full power of python also accessible to the host?
Isn't this the same concept as brython? (BRowser pYTHON)<p><a href="https://brython.info/" rel="nofollow">https://brython.info/</a><p><a href="https://github.com/brython-dev/brython">https://github.com/brython-dev/brython</a>
If I may toot my own horn, I wrote a somewhat more opinionated, reactive, frontend framework using PyScript. It's inspired by Vue.js, a bit: <a href="https://puepy.dev" rel="nofollow">https://puepy.dev</a>
I used this to create a Markdown renderer a while back. You can see the very simple source code here: <a href="https://pyscript.com/@stuartmaxwell/markdown-previewer-v2/latest" rel="nofollow">https://pyscript.com/@stuartmaxwell/markdown-previewer-v2/la...</a><p>The app won't run well on mobile but should be fine on desktop.<p>I used this code in a blog application I was writing in Django.
The big limitation that's very annoying with any WASM setup is that at the end of the day you still can't call many APIs or scrape sites because of CORS. Ofcourse, CORS is important to avoid XSS and the like but I wish there was a way to deal with this other than setting up a proxy to strip CORS, which then leaves you with a non residential IP that's more likely to get blocked.
I've been looking for something like this, but I'm still unsure it quite hits the spot. I think that this would be very interesting if it allows a person to run a blog like a Jupyter notebook.<p>I have a lightweight hack [1] that runs Python in markdown documents and can output basic images/graphs - which is embedded into static pages. The point was being able to write an article that somebody else could see the code behind it and test themselves, e.g. [2]. One of the browsers I test in is Netsurf with JS disabled. Unfortunately it doesn't look great in Lynx.<p>[1] <a href="https://gitlab.com/danbarry16/pandoc-highlight-filter" rel="nofollow">https://gitlab.com/danbarry16/pandoc-highlight-filter</a><p>[2] <a href="https://coffeespace.org.uk/projects/langtons-ant-universe.html" rel="nofollow">https://coffeespace.org.uk/projects/langtons-ant-universe.ht...</a>
First thing I tried was a small lambda function and it worked! Then I tried some Fibonacci with tail recursion and surprisingly that worked too. I'm impressed, because often when people reimplement the Python interpreter they get those wrong.
Reminds me of my first "tech" job (computer store/ISP/web dev shop, circa 1998) where the owner wrote some VBScript for the browser and wondered why it didn't work in Netscape.
This is from Anaconda and built on Pyodide:<p><i>PyScript is currently built on Pyodide, which is a “port of CPython to WebAssembly/Emscripten.” PyScript supports writing and running Python code in a browser.</i><p>Like <i>conda</i> I find the whole thing very confusing and slow, but I suppose it will be marketed to academics as "the thing to do web development with". It will also be soft-abandoned.<p>Just use Javascript, PHP or Scala like lichess.org, which is a professional website.
For those exploring, here was one of the best “Python in the browser” projects I found:<p><a href="https://brython.info/" rel="nofollow">https://brython.info/</a>
Also, check out PySheets (<a href="https://pysheets.app" rel="nofollow">https://pysheets.app</a>), which leverages PyScript to run Python logic in a spreadsheet UI, which is written entirely in Python. The PySheets UI uses LTK (<a href="https://github.com/pyscript/ltk">https://github.com/pyscript/ltk</a>), a fully client-side UI rendering library for PyScript.
Also check out <a href="https://py.cafe/" rel="nofollow">https://py.cafe/</a> (I work on this project)<p>It supports streamlit, dash, virzo and solara. Frameworks like shiny, gradio and panel are planned (maybe even fasthtml).<p>It's also really nice to integrate this into your documentation:
<a href="https://mkdocs.py.cafe/" rel="nofollow">https://mkdocs.py.cafe/</a>
I tried to write a POC Firefox extension in pyscript but ended up having to fall back to pyodide. Was a fun experiment anyway.<p><a href="https://n8henrie.com/2023/06/write-a-firefox-extension-in-python/" rel="nofollow">https://n8henrie.com/2023/06/write-a-firefox-extension-in-py...</a>
Someone just invented a whole new level of hell for devs who maintain code.<p>First it was untrained consultants and VB or Delphi (Pascal)<p>Then came the JS monkeys mixing up plain JS with jQuery and SQL injections.<p>Now it's time for data scientists and pi/sketch users to feel the pain of an uncharted domain...