Launch HN: Pynecone (YC W23) – Web Apps in Pure Python
Our Github is: https://github.com/pynecone-io/pynecone
Python is one of the most popular programming languages in the world. Webdev is one of the most popular applications of programming. So why can’t we make full-stack web apps using just Python?
We worked in the AI/infra space and saw that even skilled engineers who wanted to make web apps but didn’t know traditional frontend tools like Javascript or React found it overwhelming and time consuming to learn. On the other hand, no code and low code solutions that save time in the development process lack the flexibility and robustness of traditional web development. These tools are great for prototyping, but they can be limiting as your app becomes more complex. We wanted to build a framework that is easy to get started with, yet flexible and powerful enough so you don’t outgrow it. Our main website is fully built with Pynecone and deployed on our hosting service.
In Pynecone, the frontend compiles down to a React/NextJS app, so from the end-user’s perspective it looks like any other website. We have 60+ built-in components ranging from forms to graphing. Components are defined as Python functions. They can be nested within each other for flexible layouts, and you can use keyword args to style them with full CSS. We also provide a way to easily wrap any existing React component. Our goal is to leverage the existing webdev ecosystem and make it accessible to Python devs.
The app state is just a class. State updates are functions in the class. And the UI is a reflection of the state. When the user opens the app, they are given a unique token and a new instance of the state. We store user state on the backend, and use Websockets to send events and state updates. When a user performs an action, such as clicking a button, an event is sent to the server with the client token and the function to handle the event. On the server side, we retrieve the user's state, execute the function to update the state, then send the updated state back to the frontend for rendering. Since Pynecone is 100% Python, you can easily integrate all your existing Python libraries into your app. In the future, we hope to leverage WebAssembly to offload many operations to the client.
Once your app is built, the next big challenge is deploying it. We’re building a single-line deploy, so you can type pc deploy and get a URL of your live app in minutes. Since we specialize in hosting a single type of app, we aim to provide a zero configuration deployment process. We are still working on releasing the hosting service, but you can sign up for its waitlist on our homepage. Alternatively, you can choose to host your app with your preferred cloud provider.
Things users have built with Pynecone so far include internal apps ranging from CRM to ML tools, UIs for LLM apps, landing pages, and personal websites. If you use Python, we would love to hear your thoughts and feedback in the comments!
327 comments
[ 3.2 ms ] story [ 233 ms ] threadOne reason I looked at Dreamhost for hosting is they have an unlimited # of websites tier that is super cheap(sucks because it's php). If you can't build a payment component then some kind of pay as you go option would be cool.
By using Python in the frontend you mean the Python is transpiled into JS? The frontend uses templating or generates a SPA app?
Here's one of their examples https://pynecone.io/docs/getting-started/introduction
Back in early 2000s, i used to be more of a front-end dev...but over the years of being more of a manager (or PM or product manager) i stepped away from daily development...So, you know, I lost my touch. But a few years ago when i tried to dip back into things again, i got turned off from needing to "learn all the JS stuff". It feels all so bloated and so much work for what to me seems minimal gain. Nowadays, i much prefer back-end development (not that iots easy, but maybe it just clicks more for me without so much JS stuff)...so when i see frameworks like this one, i get more interested.
Exactly! Glad to hear I'm not alone in that boat! :-)
Given the update latency pynecone has, I can't imagine a charting library would work well.
Long time ago -for a personal project- I used CherryPy, which is simpler and easy to learn. I don't know where it stands today, but it's another option.
The API can't be easily modified -and sometimes XML responses have info JSON don't-, the website is stuck on being served through the framework instead of relying on a modern API... They even have an "old" and "new" database for albums, so when you query some of the albums through the API they come back with no tracks because the API is in the old codebase. It's a mess. And from my experience with Django, it feels a lot like the difficulties we had trying to scale and improve our existing code. It's not that you can't do things: it's just that Django isn't agile enough to adapt. You end up adapting to Django and its -beautiful and magical- ways.
Of course we could blame it on poor design choices, lack of Django knowledge or just call it technical debt... but I believe the framework is the major culprit.
For context: I haven't worked for last.fm, but I manage a third-party client (Open Scrobbler). I've been using their API for more than five years now, had interactions with their devs, read many replies in the API support forum and even tried to find undocumented endpoints that could help me (during this time I found some old profiles and test pages where you can even see screenshots of Django logs!).
Yet somehow the decades long popularity of Django, it's widespread usage and presumably many successful real-world deployments doesn't make you question your own belief?
https://pynecone.io/docs/state/overview outlines that is the case but leaves out the detail that it's using Socket.io.
Gather if you want to use this then and have it not suck you are going to need some form of edge compute.
I will def have to check this out and keep it on my radar. I used to work for a consulting place where we would have to spin up tons of one-off apps and this seems perfect for that.
Say for example, you have Model A on a server which has parameters X, Y and Z.
To load Model A in Dash is easy enough. To load its parameters as inputs with all those callbacks and imports becomes a bit messy. I've found react to just be better for that, at the end of the day.
You're headed into a place where some customers may confuse you.
I can see all the SwiftUI[0] inspiration in how to make compositions, instead of relying on CSS only.
Recently there was Rux[1] which is JSX in Rails, but that is really only dealing with ergonomics oh having Components in a nice DSL.
Then there is actual deployment story. I recently made a DRF + Next App, and I spent too much time thinking about deployment. And yea, for the volume I need to server, having a single artifact deployed, with SSR, is wonderful.
How is the intellisense support? That's one of the best features of recent JS/TS frameworks on VSCode, and I don't use JetBrains IDEs. Are there JS/CSS escape hatches? Is the goal to focus on speed of deployment or, a Python DSL over JS libraries?
Good luck either way!
[0] https://developer.apple.com/xcode/swiftui/ [1] https://github.com/camertron/rux
https://www.pycob.com
We should talk. If your open source roadmap includes getting rid of your npm dependency then we might just migrate to Pynecone for our front-end.
One nit, on your landing page it has a typo, missing "framework /that/ doesn't" > Never get locked into a framework doesn't support your existing tech stack.
Also, your Gallery has highly responsive SPAs, but for some reason the counter here[1] is very slow on a cold load
[1] https://pynecone.io/docs/getting-started/introduction
Is there a roadmap? I see the GitHub project board is pretty focused on v0.1.20. I am curious what are your plans for client side code via wasm? I feel like that is a critical missing piece for me.
https://www.django-unicorn.com/examples/click-counter
EDIT: I see that the website is generated using pynecone itself. Looks very nice - cool stuff.
I'm sorry, what?
I've just happened to run across a few of them recently as I was looking to see what else was new out there for easier ways to build quick and dirty web apps.
One question regarding the states: when do I get a new State allocated? Is it with every new tab? It's definitely not per-browser-session: if I open a new tab I seem to get a new state, while undoing a closed tab seems to recover its state with it though.
Also are old states gc'ed?
(Pretty cool, btw! Congrats on the launch)
I am not very familiar with how modern Python wsgi servers manage states, but in Java e.g. states can be cached in the heap of the one and same JVM --- can one say that the need to use an external state store like Redis is a direct result of the underlying web server having to launch multiple Python processes in order to scale up for greater loads?
It seems like there's a slightly visible lag in some of the interactions (button clicks) in the docs.
- NiceGUI was initially build for accessing and controlling hardware as shown in our webcam demo); I'm not sure how it would be done with Pynecone
- NiceGUI encourages the use of standard Python (callbacks, if-statements,..), Pynecone on the other hand uses explicit State classes and provides constructs like pc.cond and pc.foreach.
- NiceGUI uses Vue/Quasar for the frontend while Pynecone is build on NextJS
- NiceGUI generates HTML/JS/CSS via templates on the fly while Pynceone has an explicit compile step; so NiceGUI can be run with normal "Python" instead of using a command like "pc"
- while both frameworks use FastAPI for the backend, in NiceGUI you can actually use your own App and simply extend it with NiceGUI to provide additional UI; Pynecone hides FastAPI which makes it harder to provide other API endpoints (for example to serve images from memory instead of files).