@@nerdg2 it'd be interesting to see if this takes off in a big way. I've had full stack roles before where I had to learn a huge amount of front end technologies just to change some simple things on a website. Despite wanting to build web apps I got so fed up with it that I looked for a way out. Moved to backend with python and later to sysadmin. Running away from the front end and screaming. :P HTMX and FastHTML makes me interested in web dev again.
@@DavidBerglund 100% agreed, its like you read my mind. I had to learn tons of new bs just to throw them away after a tiny version update, AngularJS gave me ptsd lol. Svelte was the only sane framework i got to use. I think HTMX coupled with alpinejs should do wonders, i mean whats wrong with VanillaJS, ES6 & ES7 does wonders. I'm about to go full FastAPI and FastHTML on my new startup, i'm a 1000% commited now.
I'm not a Python developer, but I love this. I'll be crucified for saying this, but It takes me back 25 years to a time when we streamed HTML from our Java servlets, and JavaScript was something the kids used for scrolling text and popping up banners 🙂. Then, before we knew it, the kids replaced the View in MVC with another nested MVC with its own entire ecosystem, and we "full stack" devs were relegated to the back end.
Wow, I sound like a bitter boomer, but I'm not. It's just refreshing to see a simpler alternative to the complexity that is synonymous with front-end development.
@@michaelnurse9089 "never doubt yourself" is terrible advice 😂 But yes, modern front end dev is amazingly complex and this approach looks very interesting for python devs.
Tip: if you get "Internal Server Error" around 31:43 when loading the Todos page, delete todos.db and try again. If that still happens, check carefully which parameters you passed into Todo(). Unlike Titled() which accepts a string by itself as the first argument, Todo() here requires the "title=" named keyword argument.
Watching closely, the error was introduced when inserting without record id and primary key with the id. Once that is corrected, the insertion will work.
Finally things look simple and clear for how to use Python for authoring HTMX based apps. Very nicely explained with all the responses, local updates, out of band updates etc. On the other hand - I am getting sick from optimization on number of lines of code (one liners for def, if; star imports), breaking PEP8.
@@howardjeremyp Quoting Wikipedia: "A hobgoblin is a household spirit ... once considered helpful, but which since the spread of Christianity has often been considered mischievous." Regarding PEP8, I am still in the earlier stage and consider it helpful. Thanks for your work anyway - it strongly simplifies HTMX templating in very creative way and this is helpful too.
I love this, thank you for making this. I hate HTML, CSS, JavaScript, and mostly familiar with Python and C#. I'm glad I can now finally (hopefully) use Python to make a website. I believe there might be a way to even use the 'fastHTML' page to call on some Django-made pages or other logic, right? Would be awesome to get some more in-depth tech documentation.
hey jeremy, this is an amazing idea and I can see it going to be a great way of Development in future. Do we have comparisons on response time of FastHTML with others like react?
No I haven't done anything like that, because it varies so much based on what you do and how you do it. But for most apps, latency of both react and fasthtml should be low enough to be a non-issue for users.
This is extremely good. I’m: reliving the “building a blog in 15 minutes” moment I had many years ago when Rails was presented. But Jeremy is much more charismatic than DHH.
The default styling options are probably minimal. You can always insert JS elements and so have access to near infinite styling options if that is what you need. Most viewers don't care for fancy styling.
This is really cool! Finally python is paying off. But one concern is that I went to the deployed app from this tutorial and tried using it. The app seemed very slow for a simple to-do list app. It was taking a moment to add or delete new todo. Makes me worry about how slow bigger projects would be.
looks great!! I am new to all this, I have learend python for data analysis and also learned fastAPI for backend, can I use it for frontend with fastAPI to create a full stack app?
Yes, it's more scalable in fact, since you can use the full power of python to refactor. Also the actual size of the html partials sent over the wire are often more compact than json APIs, and the browser has far less work to do -- there isn't a "hydration" process.
Well, that's a great overview. Thank you so much!! We use DRF to create rest APIs using Django. And FastAPI to create rest APIs too that can be consumed by any frontend/client for that matter. What's up with this one? Can we do that stuff? If so or not, can you please make a walkthru in that perspective? Or is this like plain-old standalone Django with just templates that serve only HTML with no rest APIs?
It's neither of those things -- it's something new! You can do the same stuff that you do with DRF/FastAPI with a js frontend, but you don't need to write any js frontend. There's about a dozen examples and walkthrus in the repo so take a look.
Curious to learn how this compares to Sameul Colvin's FastUI - similar name and you both seem to be aiming for a similar developer experience of writing low boilerplate web apps purely in Python and you both mention being FastAPI/htmx inspired.
Great question! It's because the `Todo` type annotation is there. So FastHTML tries to create an object of that type using the named items in the form.
Would progressive web app features work with this such as SPA to provide navigation without reloads and access to device features on mobile such as offline storage on device with indexedDB or WebSQL on device?
@@howardjeremyp thanks looking for something robust to build a full scale production app with the flexibility of css js and html for the frontend and robust flask app for back end applications
@@frag_itthen you're surely not going to pick this brand new shiny thing. Go with Flask/Django/FastAPI+Templates and HTMX. Proven tech. I'm saying this being genuinely excited about FastHTML
@@frag_itmaybe don't jump on a new shiny web framework for a new production app when you can use a more mature framework like Flask or Django with HTMX if you like. I'm excited for the future of this project though. But then again, if this framework let's you build and test and iterate on your ideas quickly. Why not!
my hx_swap_oob="true" becomes hx-swap:oob="true" when rendered to HTML. And because of that issue the Input field is not cleared. Does anyone know how to solve this issue?
In order to have wider adoption of this wonderful library, we need to solid documentation so that people can take it from day one. For now, i am just struggling for get hand on
Maybe, you don't know! Div and other components are classes and it is a convention in python that all classes name must start with a capital letter. Functions and other variables may be in lowercase but classes must be capitalised. This is a convention and it is not compulsory to adhere to it. However, FastHTML follows this convention which improves the understanding of the project structure by python developers.
This bugged me as well. htpy is a package that generates HTML and it uses lowercase. I like how it looks but I'm not sure how complete it is or limiting etc
I have been thinking about this idea for quite a while. A very huge first step. Thanks. However we need a neater approach to code interactive web with Python. I would focus on interactivity, component based architecture, existing styling frameworks and browser-Python compatiblity first rather than database and backend. Well done. Wish you best of luck. I'm looking forward for the day where I will use Python for my entire web app with fair confidence.
Does it make sense to use FastHTML as pure frontend that calls an API backend created with FastAPI? I see that here FastHTML is kind of doing both frontend and backend.
No it doesn't - FastHTML is designed for hypermedia applications, which is the design we recommend most people use for most projects. If you want to split out the API and deal with the complexity of that approach, then you should use something designed for that.
Really cool idea. I think with more work and simplified commands could be great. Right now, it's probably good for pythons devs for small projects but not something I'd expect to see in many production sites. Code seems just as complex as righting out the html. Especially with all the tools available now. Html5 is super simple.
Side question: As a beginner, what do I need to learn to contribute to this project? I know python and web development. Still I didn't learn git and other things.
I am sorry but this is a rehash of the past, trying to abstract away the web (HTML & JavaScript) with a programming logic failed many years ago and here we are again.