Automated Action a2ba7e0a54 Fix port binding issue with dynamic port selection
Added port conflict resolution to handle cases where port 8001 is already in use.
The app now checks if a port is available and incrementally tries higher ports
until it finds one that's free.

generated with BackendIM... (backend.im)
2025-05-14 01:26:28 +00:00

2.0 KiB

Quick REST API Service

A fast, lightweight REST API service built with FastAPI and SQLite.

Features

  • FastAPI Framework: High-performance async API framework
  • SQLite Database: Simple, file-based database with SQLAlchemy ORM
  • Async Support: Full async/await pattern for high concurrency
  • Migrations: Database versioning with Alembic
  • API Documentation: Auto-generated OpenAPI docs
  • Health Endpoint: Monitoring endpoint at /api/v1/health
  • CRUD Operations: Complete REST API for item resources

Project Structure

.
├── app
│   ├── api
│   │   └── v1
│   │       ├── __init__.py 
│   │       ├── health.py
│   │       └── items.py
│   ├── core
│   │   └── config.py
│   ├── db
│   │   ├── __init__.py
│   │   ├── base.py
│   │   ├── session.py
│   │   └── migrations/
│   ├── models
│   │   ├── __init__.py
│   │   └── item.py
│   └── schemas
│       ├── __init__.py
│       └── item.py
├── alembic.ini
├── main.py
├── requirements.txt
└── README.md

Installation

  1. Clone the repository
  2. Install dependencies:
    pip install -r requirements.txt
    

Running the Application

Start the server with:

python main.py

Or manually with uvicorn:

uvicorn main:app --host 0.0.0.0 --port 8001 --reload

The application will automatically find an available port if the default port (8001) is already in use.

The API will be available at http://localhost:8001.

API documentation is available at:

API Endpoints

  • GET /api/v1/health - Check API health
  • GET /api/v1/items - List all items
  • POST /api/v1/items - Create a new item
  • GET /api/v1/items/{item_id} - Get a specific item
  • PUT /api/v1/items/{item_id} - Update an item
  • DELETE /api/v1/items/{item_id} - Delete an item