Show HN: Pynecone – Web Apps in Pure Python (github.com)
Hello, we just launched the alpha release of Pynecone - a way to build full-stack web apps in pure Python. The framework is easy to get started with even without previous web dev experience and is completely open source / free to use.
We made Pynecone for Python devs who want to make web apps, but don’t want the overhead of having to learn or use Javascript. We wanted more flexibility than existing Python frameworks like Streamlit/Dash that don't allow the user to make real, customizable web apps.
With Pynecone, you can make anything from a small data science/python project to a full-scale, multi page web app. We have over 60+ built-in components and are adding more.
We are actively trying to grow this project so no matter you skill level we welcome contributions! Open up an issue if you find missing features/bugs or contribute to existing issue.
101 comments
[ 0.32 ms ] story [ 155 ms ] threadIn Pynecone, the frontend compiles down to a NextJS/React app, and the backend is a FastAPI server. Events are sent as network calls that update the app state, and the state delta is sent back to the React app, which updates the UI.
Best guess is OP's package gives finer grained control over display elements, which definitely has a place.
[0] https://blog.streamlit.io/how-to-build-a-real-time-live-dash...
Gradio seems more popular for building ML driven demos though I have not used it. (I actually am curious why it’s more popular than SL).
Anvil is another “python web app” project I poked at briefly but didn’t get far
But to keep it short there is a way to get rid of this in the future and we are currently working on it. So the only installation step will be `pip install pynecone-io`
The idea being that a project like yours can install node into a venv on install for use itself. No more dual stack environments!
> height="100vh",
> bg="radial-gradient(circle at 22% 11%,rgba(62, 180, 137,.20),hsla(0,0%,100%,0) 19%)",
Smells like leaky abstractions. Surely it's possible to abstract this into a strongly typed API?
Edit: https://pynecone.io/ looks a little screwed up for me on FF 107: https://i.imgur.com/ICu29UL.png
Thanks for pointing out the UI bug, we'll work on a fix!
One thing I could not find, skimming the docs, was where the CSS lives. Could I place my own existing css stylesheet(s) in the project? Would the snake_case equivalents just fall through to the underlying CSS, or would I need to write a CSS dictionary as a translation layer?
Thanks.
Unless I'm misunderstanding how CSS support works here, I think this is a deal breaker for me at the moment. Being able to include external stylesheets/frameworks is something of a must have.
Appreciate it is Alpha level software so look forward to learning how the project evolves.
We actually make our whole website and docs in Pynecone where as streamlit could never do this.
Don't let my skepticism (below) to detract from your accomplishment.
I am deeply skeptical not only about this tool in particular but about these tools (e.g., Dash, Panel, Streamlit &c.) in general. I've seen these tools work well for very simple use-cases, but they seem to require some combination of…
· cooperating requirements (matching exactly what the demos do, so you stay completely within the “regime” these tools support)
· upfront knowledge of all requirements (so that you never fall out of this regime)
· the ability to reject requirements (so that you can keep yourself within the regime, though this means the tool is leading the business, not the business leading the tool)
· the ability to accurately identify the boundaries of the regime from the tool documentation and design
For very simple examples, it's may be possible to stay within these constraints, but even when you manage to successfully use these tools, you do so at high (and, in my view, often unacceptable) risk.
In general, the risk/reward for a tool like this is about being able to learn the tool almost immediately (which must also account for time spent trawling through the documentation or the Github issues or even the `dir(module)` to figure out how to spell that one thing you need.) Basically, if you can create something in 1 day that can last for 180 days before a requirement comes along that forces you to start over from scratch, you may be okay.
You certainly never want to become good at these tools; the more you invest in the tooling, the harder it will be to abandon it when it is no longer appropriate, and the more willing you will be to accept contortions that you will inevitably regret. You certainly never want to spend more than a trivial amount of time building something with these tools, since the risk of needing to rebuild or abandon the technology is simply too high.
(Personally, I simply don't think React is that hard to learn, that hard to teach, or that onerous to use…)
In particular, this tool's API seems particularly risky. e.g., in the example code, there is a section like this:
So we're encoding the control flow defining the layout in some sort of object graph (some sort of pseudo-AST)? It's not going to take a lot of this to spiral out of control. Unless you can recognize that this tool is unsuitable for even mildly complex programmatic component layout (which is trivial to do in React,) you're going to hit an impassible brick wall trying to handle what will otherwise be considered a benign business request.I suspect, however, that this API is still being refined. After all, what if I wanted to trigger on two conditions? There are probably some sophisticated `metaclass` mechanisms wrapping the `State` attributes in some symbolic modelling, but SymPy shows us that this is not trivial to get right, and the Python object model constraints you in unpredictable ways. Without looking at the code, I suspect you cannot `cond(State.mode1 | State.mode2, element)` and probably have to create some sort of `State.mode1_or_mode2` subordinate data, which spirals out of control pretty quickly. And what if you want to do `cond(State.mode | mutable_global_mode)`? And so forth and so on.
There are so many structures and modalities for control flow and data flow (trivially expressible in React) that will become clumsier and clumsier to express in with this modelling, and unless you can anticipate that they won't arise, reject the business requirements that mandate them, or (with no regret) throw everything away and start over from scratch, you're going to have a good experience.
For you react/js was easy to learn but a lot of people don't want to take the time to learn this. At the end of the day every one has a preference and I see where you are coming from on this.
> Robust: Get production-ready code. With automatic interactive documentation. [1]
> FastAPI framework, high performance, easy to learn, fast to code, ready for production. [2]
[1] https://fastapi.tiangolo.com/ [2] https://twitter.com/FastAPI
A succinct explanation of the underlying design is the best way to get me from "oh that's cute" to "wow, I want to try this".
https://wiki.pine64.org/wiki/PineCone
[0] https://botanicalgarden.berkeley.edu/glad-you-asked/cones
https://en.wikipedia.org/wiki/Microsoft_v._MikeRoweSoft
https://en.wikipedia.org/wiki/Microsoft_Corp._v._Lindows.com....
https://www.uspto.gov/trademarks/search/get-ready-search-cla...
How does it compare to Flask framework?
I’ve been waiting for it as I love streamlit but it’s so limiting.
Happy to help with anything if I can. I’d try to move our next version of our API portal to it
Do you mean being in hacker news ?
While I've not worked with it, one example of Djangonic Components might be Wagtail's: https://docs.wagtail.org/en/latest/extending/template_compon...
Interested in others' thoughts on what Pynecone will do better.
I think a better approach would be to make the back end pluggable to put whatever backend framework you want. And then you don't have tell people "well you can't use this fancy new tool, unless you move your entire stack over to fastapi..."
I mean there doesn't seem to be any reason you can't have a PineConeView that subclasses the django View class...
https://anvil.works/
Anvil seemed a little outdated for me to personally use but to each their own.
Thank you for putting it out there!
Very similar to what we do on Flet: https://flet.dev The major difference is that Flet uses Flutter to build UI and can target desktop, web and mobile. Also, we use WebSockets for communicating with the server which gives lower latency (the delay between a click on a button here https://pynecone.io/docs/getting-started/introduction and UI update could be annoying).
We thought about adding web socket and are still debating. The latency here is not from our framework though its from our server getting slammed with hacker news and reddit from our launch lol. We found the overhead of sockets not worth to for the majority of our apps.
Seems like this could be a major barrier to scaling, especially if /all/ reactive state has to be handled through the server. Maybe a future feature could be a WebState class that provides reactivity only on the front end?
I have 3 questions for the team. Who is the target audience exactly? How is this different from Anvil, Toga, Streamlit or the previous 36 attempts? And if learning JavaScript is too difficult, what exactly makes shoving the DOM API into another language easier? You still need to learn all the same things but now there’s about 9 orders of magnitude less working examples to copy from.
The barrier of writing both a front and backend for a simple demo/viz tool is pretty high (relative to the time it takes).
"Requires NodeJS"
But to keep it short there is a way to get rid of this in the future and we are currently working on it. So the only installation step will be `pip install pynecone-io`