FastAPI + EdgeOne Pages
High performance, easy to learn, fast to code, ready for production. Modern, async, blazing fast.
cloud-functions/api/[[default]].py
from fastapi import FastAPI
from pydantic import BaseModel
import time
app = FastAPI()
class UserCreate(BaseModel):
name: str
email: str
@app.get("/")
async def root():
return {
"message": "Hello from FastAPI Cloud Function!",
"framework": "FastAPI",
"timestamp": time.time()
}
@app.post("/users")
async def create_user(user: UserCreate):
return {"id": 1, **user.dict()}API Endpoints
GET/api/info
Returns FastAPI app metadata with Pydantic response model
GET/api/users/42
Fetch user by typed path param (user_id: int)
POST/api/users
Create user with Pydantic UserCreate model validation
Request Body:
{
"username": "alice",
"email": "alice@example.com"
}GET/api/search?q=fastapi&limit=3
Search with Query() params — includes ge/le validation
High Performance
One of the fastest Python frameworks available, on par with NodeJS and Go
Auto Documentation
Interactive API documentation with Swagger UI and ReDoc built-in
Async Support
Native async/await support for high-concurrency applications