Modern APIs with FastAPI and Python Transcripts
Chapter: Building our first API
Lecture: Concept: A minimal API endpoint
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Now that we've built our first FastAPI endpoint,
0:03
let's just review what it takes to get a minimal API endpoint up and
0:07
running in an application. Pretty simple.
0:09
So we're gonna import FastAPI to use FastAPI and then
0:12
we have to have a server to run it,
0:14
so we're gonna use uvicorn,
0:16
and we create an instance of the FastAPI object, calling it
0:20
"api", create a function, some kind of method that we're going to call,
0:24
and we're gonna decorate it with http verbs and their configuration.
0:29
So an http get against api/calculate will run this right here.
0:35
And then we just say "uvicorn.run"
0:37
we pass it the API object,
0:39
we say the host and we say the port and that's it, we're off to the races.
0:43
We have our app up and running.