back to indexIntro to FastHTML
00:00:08.560 |
Have a look at some of these things that we made. 00:00:11.200 |
- So this first example is a chatbot that I made 00:00:43.040 |
It's maybe the most uninteresting one in some ways, 00:00:45.640 |
but I like it 'cause it's an example of like everything. 00:00:53.520 |
And that entire thing also fits onto a single screen 00:00:59.840 |
- Other people are making cool stuff with this as well. 00:01:02.080 |
If you know a bit of web programming already, 00:01:06.000 |
Legendary author and web programmer, Daniel Roy-Greenfield, 00:01:11.520 |
And within 45 minutes of starting out with FastHTML, 00:01:15.360 |
"Look, I've just created a complete blog system." 00:01:29.600 |
What we've heard though, and we found ourselves, 00:01:31.640 |
is that when you're ready to go to the next level 00:01:36.160 |
things like this require rewriting from scratch 00:01:41.760 |
Lots of people have created lots of fantastic 00:01:53.640 |
setting up a new project example in less than five minutes. 00:01:59.800 |
is with something like FastAPI on the backend 00:02:02.680 |
and something like React or Svelte or Vue on the front end. 00:02:06.960 |
You can create nice, sophisticated apps with this, 00:02:20.360 |
I've been writing web applications for years. 00:02:22.920 |
I created the framework that FastMail is built on. 00:02:31.000 |
A lot of what I learned from that is now built into this. 00:02:36.640 |
to create web frameworks and to create web applications. 00:02:41.800 |
of my tutorials on Flask, AngularJS, C#, and so forth. 00:02:46.800 |
With FastHTML, this is by far the most excited 00:02:55.840 |
and I can't wait to see what you can do with it. 00:03:04.600 |
to create this source code that you see here. 00:03:09.400 |
Can you show us how to create the scaffolding 00:03:21.040 |
- Wait, what about the front-end JavaScript code? 00:03:30.720 |
Let's start typing the Python file right now. 00:03:45.480 |
And here we're displaying some code and running the app. 00:03:51.880 |
so you can see all the changes that you make in real time. 00:03:58.120 |
but we don't have to type the HTML ourselves. 00:04:00.960 |
And so FastHTML has all of these built-in tags 00:04:11.320 |
and we're seeing if we can display that component. 00:04:17.600 |
We can create these with Python list comprehensions 00:04:23.120 |
So let's add a form that lets us specify new to-dos. 00:04:31.520 |
what we're going to do here is do something called HTMX, 00:04:36.160 |
We trigger an event, send a message to our server, 00:04:40.080 |
that responds to that, in this case, post request, 00:04:46.240 |
HTMX also lets you, doesn't refresh the whole page, 00:04:50.080 |
so that's why we have the to-do list section here. 00:04:53.000 |
And we're adding to the end of it any new to-dos 00:04:56.600 |
- All right, so let's add some persistency to this app. 00:05:09.720 |
So in our Fast app, we can set where our database 00:05:13.360 |
is going to be stored and some of the fields, 00:05:16.440 |
as well as which one's going to be the private primary key. 00:05:24.200 |
and go through all of the to-dos in our database. 00:05:27.560 |
If we refresh that, we can see that it gets returned, 00:05:38.240 |
We don't really render the returned post request, 00:05:43.560 |
HTML, so let's go ahead and add a little rendering function 00:05:53.480 |
now we have a very beautiful rendering of the to-dos. 00:05:58.480 |
- So from here, really, it's just about adding 00:06:09.000 |
but you can now create them as Python functions. 00:06:11.280 |
You can compose them together to create component libraries 00:06:19.960 |
So here, let's go ahead and add a delete link as well. 00:06:43.600 |
by taking advantage of basic auth in your web browser. 00:07:07.080 |
And you can deploy it with a single line of code 00:07:14.080 |
- So we've all been having a ton of fun writing examples. 00:07:18.000 |
We're gonna keep adding more and more examples 00:07:21.080 |
And I think you'll be able to get something there 00:07:24.560 |
and we're really looking forward to seeing what you build.