Skip to content

Latest commit

Β 

History

History
88 lines (64 loc) Β· 2.62 KB

File metadata and controls

88 lines (64 loc) Β· 2.62 KB

Python Cloud Functions - FastAPI | EdgeOne Pages

A demonstration website showcasing how to deploy high-performance FastAPI applications as serverless functions on EdgeOne Pages.

πŸš€ Features

  • FastAPI Framework: Modern, fast (high-performance) web framework for building APIs
  • Automatic OpenAPI: Swagger UI & ReDoc documentation generated automatically
  • Pydantic Validation: Automatic request/response validation with type hints
  • Async Support: Native async/await for high performance
  • Type Safety: Full Python type hints support

πŸ› οΈ Tech Stack

Frontend

  • Next.js 15 - React full-stack framework
  • React 19 - User interface library
  • TypeScript - Type-safe JavaScript
  • Tailwind CSS 4 - Utility-first CSS framework

Backend

  • FastAPI - Modern Python web framework
  • Pydantic - Data validation using Python type hints
  • Cloud Functions - EdgeOne Pages serverless functions

πŸ“ Project Structure

python-fastapi-template/
β”œβ”€β”€ src/                    # Next.js frontend
β”œβ”€β”€ cloud-functions/        # Python cloud functions
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── [[default]].py # FastAPI application
β”‚   └── requirements.txt   # Python dependencies
β”œβ”€β”€ public/                # Static assets
└── package.json          # Project configuration

πŸš€ Quick Start

Requirements

  • Node.js 18+
  • Python 3.9+
  • EdgeOne CLI

Install Dependencies

npm install

Development Mode

edgeone pages dev

Visit http://localhost:8088 to view the application.

🎯 API Endpoints

Method Path Description
GET /api/ Root endpoint
GET /api/health Health check
GET /api/info Function information
GET /api/time Current server time
GET/POST /api/echo Echo request info
POST /api/json Handle JSON body
GET /api/users/{user_id} Get user by ID
POST /api/users Create new user
GET /api/search Search with query params
GET /api/docs Swagger UI documentation
GET /api/redoc ReDoc documentation

πŸ“š Documentation

Deploy

Deploy with EdgeOne Pages

πŸ“„ License

This project is licensed under the MIT License.