FastApi

FastAPI: Modern Python Web Framework

FastAPI is a modern, high-performance Python web framework for building APIs with ease and speed. It's gained significant popularity in recent years due to its simplicity, automatic documentation generation, and the performance boost it offers. As a geeky DevOps professional with 15 years of experience, I find FastAPI to be a fantastic choice for creating APIs, especially in microservices and containerized applications.

Key Features:

Why Choose FastAPI?

Example: 

from fastapi import FastAPI

app = FastAPI()

@app.get("/")

def read_root():

    return {"message": "Hello, World!"}


This is a simple FastAPI application that defines a single GET endpoint ("/") that returns a JSON response.

To run this example create a folder called "app".  In the folder app create a "main.py" file with the above code in it. then it is as simple as  "uvicorn app.main:app --host 0.0.0.0 --port 8000"

This command tells Uvicorn to look for a FastAPI instance named app in the main.py file inside the app directory.

Access the Application: Once the server is running, you can access your application by going to http://127.0.0.1:8000 in your web browser. You should see the JSON response {"message":"Hello, World!"}.

In summary, FastAPI is a powerful, modern Python web framework that combines high performance with developer-friendly features. It's an excellent choice for building APIs quickly and efficiently, making it a valuable tool in the DevOps toolkit for building and managing web services.