top | item 33547813

Show HN: Hstream – quick Python web apps – Streamlit alternative using htmx

104 points| conradbez | 3 years ago |github.com

I love Streamlit but have run into many situation where taking it from PoC to MVP state is insurmountable.

With all the recent HN hype around htmx and sematic html / classless css I decided to build a Streamlit alternative using these on top of FastAPI.

This has a couple advantages: 1) easier to extend when you move past PoC since the FastAPI app is exposed (allowing adding more routes) and hstream acts more like a typical web stack 2) with htmx and html (plus MVP.css) doing the heavy lifting the package is alot less complex and easier to reason about - and hopefully more performant eventually 3) html is simple, so using this we can give the user much more control around the look and feel, while falling back onto MVP.css (classless css) sane defaults.

Would love to hear people's thoughts.

18 comments

order

silver-arrow|3 years ago

Big fan of HTMX here. We have found it more productive for our team than the more mainstream JavaScript React type libraries for the majority of the dynamic web apps we build. It seems so much easier to grasp the server-side rendering hypermedia model. In addition, the simplicity of the development tools and process is far better. Love the model of HTMX with some _hyperscript sprinkled in. In the rare use cases this model won't suffice, then and only then do we plug in something more JavaScript heavy - not very often!

sandGorgon|3 years ago

could you talk about it a bit more ? especially for a react person. How would you term the developer experience of htmx?

ZeroCool2u|3 years ago

So, I've had a lot of the same issues with Streamlit in terms of going beyond the very raw PoC phase, which is why we often end up using Plotly's Dash[1] framework (React + Flask) at work for this kind of task.

Taking a step back, what would the benefits be compared to Dash?

[1]: https://dash.plotly.com/

conradbez|3 years ago

When dash came out I was a massive fan but found the abstraction layer not quite right.

When writing a python script you tend to think from top to bottom - as your script runs through. Dash adopts the html approach of defining a document and callbacks. After doing the refactor to this model I found the trade-offs of Dash wasn't worth the time saved of going straight to a more traditional stack, and again you're pretty locked-in to this choice now.

One example was writing a Dash SSO component turned into quite an ordeal (more so than most SSO integrations) - my aim here is to make an extension like this easier because you've got access directly to the FastAPI app with `hs.app`.

zachwill|3 years ago

Huge fan of Streamlit — I've used it a ton at work — and HTMX + Django is my preferred method for building larger sites. Cool work!

boxed|3 years ago

Writing an API that scales from quick PoC to MVP to serious production is in my opinion a problem space that is mostly not explored. We've tackled this with iommi (https://docs.iommi.rocks) with deep customization while at the same time having super fast PoC. We are not satisfied with the performance yet though, but at this point it's good enough for most uses.

conradbez|3 years ago

Wow this looks awesome! Definitely have a bit of a browse, thanks!

nvusuvu|3 years ago

What's PoC mean?

unoti|3 years ago

> What's PoC mean?

Proof of Concept, or initial prototype.

knowsuchagency|3 years ago

I think the demo site may have been hugged to death. It's not rendering anything for me.

I think it's also worth giving a shoutout to wave in this space; they have quite a few components you can use out-of-the-box https://github.com/h2oai/wave

abraxas|3 years ago

I'm quite the fan of streamlit but do not love its way of handling state. The only way to have a semblance of state captured between browser refreshes in streamlit is through query params. Have you taken a bite at that problem in your framework?

shapiromatron|3 years ago

This looks fantastic and the streamlit API is lovely to with with so it seems like a nice approach. Like others on this thread I’m a big django developer too; it’d be nice if the backend was swappable so you could run on flask or django as well…

conradbez|3 years ago

Thanks! Yeah interesting idea on the swappable backend, something I'll consider.