#100DaysOfWeb in Python Transcripts
Chapter: Days 9-12: FastAPI
Lecture: A home page of sorts

Login or purchase this course to watch this video and the rest of the course contents.
0:00 There is one more thing I think we should check out and fix before we move on from this simple calculator API.
0:07 Recall, when we run it, we can go over and we can go to whatever this URL port is here, slash API slash calculate and pass x and y.
0:16 And that works great. But if we just go to the server, something bad happens, we get a 404 not found, right? See this?
0:24 And if we actually pulled up the dev tools, you would see the response code is 404 not found.
0:29 So it's not ideal for just the homepage or the domain name of your API. So let's take the smallest measures here.
0:37 And we'll take bigger measures later to improve upon this. Let's just do a little bit of tiny work here so that we can have something.
0:44 So let's go API, I want to do a get to forward slash, whatever we write next is what's going to happen when you just request the server by itself.
0:51 So I'm going to create a call index. And I'm going to paste some text here, I'm going to have a body which has some HTML,
0:59 the body, then the head, and then a div. And maybe it even needs a HTML slash HTML to be proper, even though it would have worked before.
1:09 And we can just use what we knew before we can just return a FastAPI dot responses dot HTML response.
1:16 And what do we want to set the content is this body. All right, that's it. And we had a little continuation character there. Now, now that's it.
1:25 Nothing else got messed up. Okay, good. So let me just rerun this. I'm gonna click here now. Yes, welcome to the super fancy API.
1:33 And now if we click on that, it takes us over to our actual API, because it just seemed
1:39 wrong that you opened up the server and it just says crash, this is not working.
1:43 So here's a little tiny bit of work that we can do stuff we've already discussed of just
1:48 passing back some alternative response besides JSON and hooking this.
1:54 Actually, this is the gateway to having a whole bunch of pages and stuff on our site.
1:58 If we wanted, we're going to talk more about using things like Jinja templates, and maybe even better templates later.
2:04 But for now, this will at least let our site work in a way so it doesn't look broken. And then we can go on and work with our API here.
2:12 So that's a quick introduction to FastAPI. You can see it's super clean, super easy. And there's tons of neat stuff that we haven't even gotten to yet.


Talk Python's Mastodon Michael Kennedy's Mastodon