Member-only story
FastAPI: In Just 1 Minute Create Your First API Using FastAPI
Fastapi is an another most popular framework of python for building powerful web api’s just like Django. FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints. python for building powerful web api’s just like Django. FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
Installation
Before move to create our first api, let’s install these two required dependencies.
pip install fastapi
pip install "uvicorn[standard]"
Let’s create an API
Now create a main.py file and open it in any code editor.
# main.py
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
Run the Server
To start the development server just hit this command in your terminal.
uvicorn main:app --reload
It will start the development server on the default port 8000
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)