2.Python | FastAPI | Clean Architecture | Setup FastAPI And Doc (OpenAPI)
YouTube transcript, YouTube translate
A quick preview of the first subtitles so you know what the video covers.
Let us continue over here and let's go and create our first API endpoint. And before that we need to go and install our first API dependency over here. And to manage the dependency in our clean architecture, we are going to follow our separation of function and let's add the new file over here. And let's call this one something like the we need to name this one as the requirement. TXT, right? So make sure that the file name is correct which is of the requirements txt over here. And here we need to add the fast uh API with the standard version. And I'll just go and add the standard version over here. With the standard version, it comes with all of the required packages for our development, right? And we don't have to go and manually install like the UV con and all of those stuff. We are going to get it with the standard package of the fast API. And once we have this particular or the file which is of the requirements, we need to go and install the fast API dependency and that will be from the pip ins and then the requirements. PXT over here. And let's go and install all of those dependencies. And now you can see that it has basically installed all of the dependencies for us. Right? And once the dependency has been successfully installed, let's go go and add the our main.py file. You can just go and create the main dy file or we will be following the clean architecture. So let's just go and add the app directory over here. And inside of the app directory, I'm going to move all of my the Python file which is of the main.py file over here. And let's from the fast API, I need to import the fast API over here. And let's create the app over here which will be of the fast API. So let's go and initialize our fast API over here. And that will be of the app. You can obviously call the other name over here variable name but the the best practice or the default is always the app over here and using that particular app what I can do is let's go and create one of the default endpoint which will be of the get and that will be at the root and let's create one function that is to this is a python function def read root or you can just call the read root or get root or something so let's say since this is a get method I'll just go and call this one as a get root over here. This will be to get the root of our directory.