Create First App Using FastAPI

Get started with creating your first app using FastAPI.

We'll cover the following...

Create a simple FastAPI app

In the previous lesson, we have already set up our environment to run FastAPI applications. Let’s now look at a simple FastAPI code:

from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def root():
  return {"message": "Hello World"}
Simple app using FastAPI

To start the server, you need to run the following command:

uvicorn main:app --reload

Here, main refers to the file name and app refers to the object of FastAPI created inside the main.py file. The --reload parameter makes the server restart after ...