Back to Templates

Python FastAPI - Cloud Functions on EdgeOne Pages

Deploy FastAPI applications with auto-generated OpenAPI docs, Pydantic validation, and async support.

View Demo
Deploy FastAPI applications with auto-generated OpenAPI docs, Pydantic validation, and async support.

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

MethodPathDescription
GET/api/Root endpoint
GET/api/healthHealth check
GET/api/infoFunction information
GET/api/timeCurrent server time
GET/POST/api/echoEcho request info
POST/api/jsonHandle JSON body
GET/api/users/{user_id}Get user by ID
POST/api/usersCreate new user
GET/api/searchSearch with query params
GET/api/docsSwagger UI documentation
GET/api/redocReDoc documentation

๐Ÿ“š Documentation

๐Ÿ“„ License

This project is licensed under the MIT License.