Skip to content

tirthraj07/FastAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FAST API

What is FastAPI? FastAPI is a modern Python framework used for building APIs. It is known for:

1. Extremely high performance

  • Built on ASGI instead of WSGI
  • Uses Starlette (fast async networking)
  • Uses Pydantic for ultra-fast validation
  • Benchmarks close to Node.js and Go

2. Automatic Swagger UI

Go to:

http://localhost:8000/docs

You get full API docs automatically.

3. Automatic data validation

Pydantic models ensure that every request is validated.

4. Async, easy, modern

Built for async/await.

Install FastAPI with UV

Step 1: Initialize the project with uv

uv init

This creates:

pyproject.toml
README.md
.python-version
uv.lock
main.py

Step 2: Install FastAPI + Uvicorn

uv add "fastapi[standard]"

This installs:

  • FastAPI
  • Uvicorn
  • Pydantic
  • Starlette
  • Other required extras

Step 3: Create the recommended folder structure

Inside your project directory, create these folders:

fastapi-demo/
│
├── src/
│   ├── app/
│   │   ├── main.py
│   │   ├── models/
│   │   ├── routes/
│   │   ├── schemas/
│   │   ├── database/
│   │   ├── core/          # config, settings, security
│   │   ├── utils/
│   │   └── __init__.py
│   └── ...
│
├── pyproject.toml
└── README.md

Step 5: Create your first FastAPI app

Create:

src/app/main.py

Write:

from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def home():
    return {"message": "Hello FastAPI!"}

Step 6: Run the server

Run the app via uv:

uv run uvicorn src.app.main:app --reload

With Port:

uv run uvicorn src.app.main:app --reload --port 8000

Open in browser:

http://localhost:8000
http://localhost:8000/docs

FastAPI environment is now correctly set up.

About

A Spring Boot style FastAPI Boilerplate code that contains custom configurations, OIDC Support, Auto Environment Configuration and custom middlewares, exception handlers, etc

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages