# FastAPI_learn_with_ANIK

FastAPI is a Python framework used to build APIs quickly and easily. It helps connect different apps like mobile, web, AI services, and databases through HTTP requests.

In the diagram, the server is the main backend system. The mobile app and web app send requests to it, and the server communicates with other services like AI servers and databases.

![](https://cdn.hashnode.com/uploads/covers/65b7e5922bf7111b587cdd17/1e04bc31-b763-46a9-b01b-6c351e58362a.png align="center")

The most common request types are:

*   GET → read data
    
*   POST → create data
    
*   PUT/PATCH → update data
    
*   DELETE → remove data
    

FastAPI makes this simple by writing route functions like:

```python
@app.get("/orders")
def get_orders():
    return {"message": "Orders fetched"}
```

It is popular because it is:

*   fast
    
*   easy to learn
    
*   supports async programming
    
*   generates automatic API documentation
    

So, in short: FastAPI is a tool to build backend APIs that connect apps with data and services.

## **Web Request Client**

A web request client is a tool or program that sends a request to a server and receives a response

![](https://cdn.hashnode.com/uploads/covers/65b7e5922bf7111b587cdd17/7817ffde-748d-414b-a51c-34c04e763ff4.png align="center")

This backend diagram shows how a web application works. The mobile app and web app send requests to the backend server, which processes them and communicates with databases or AI services. The server handles different request types such as GET, POST, PUT/PATCH, and DELETE to read, create, update, or delete data. Tools like Postman and web request kits are used by developers to test these requests before connecting everything together. In short, the backend is the central part of the system that receives requests and returns responses.

![](https://cdn.hashnode.com/uploads/covers/65b7e5922bf7111b587cdd17/8563e966-61c9-448a-9272-8cb94e1d1ff7.png align="center")

### **Flask is sync**

It handles requests one at a time in a traditional blocking way.

When a Flask app receives a request, it does the work in a normal single flow. It waits for each task to finish before moving to the next request.

### Example

If one user sends a request that takes 5 seconds, Flask may wait during that 5 seconds before handling another request.

Flask does not have built-in request validation like FastAPI. In Flask, if you want validation, you usually need to write manual checks yourself or use extra libraries like:

*   Flask-WTF
    
*   Marshmallow
    
*   Pydantic + Flask integration
    

Flask does not provide built-in interactive API docs like FastAPI.

![](https://cdn.hashnode.com/uploads/covers/65b7e5922bf7111b587cdd17/8b055310-dc19-447f-88d2-af47b37d459d.png align="center")

![](https://cdn.hashnode.com/uploads/covers/65b7e5922bf7111b587cdd17/a802f64d-b06d-4773-bf97-0d07698eb5f2.png align="center")

## Web Framework

| WSGI | ASGI |
| --- | --- |
| Web Server Gateway Interface | Async Server Gateway Interface |
| One request at a time per worker | Many Request per worker |
| One Delivery Partner (DP) per order | One delivery partner picks up multiple order |
