Python + EdgeOne Pages
Deploy lightweight Python serverless functions on EdgeOne Pages without any web framework dependency. Pure Python, maximum performance.
cloud-functions/api/[[default]].py
import json
import time
from http.server import BaseHTTPRequestHandler
class handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'application/json')
self.end_headers()
self.wfile.write(json.dumps({
"message": "Hello from Python Cloud Function!",
"timestamp": time.time()
}).encode('utf-8'))API Endpoints
GET/api/info
Returns function metadata including runtime and version info
GET/api/users/42
Fetch a user by dynamic URL path parameter
POST/api/users
Create a new user with JSON request body
Request Body:
{
"username": "alice",
"email": "alice@example.com"
}GET/api/search?q=python&limit=3
Search with query parameters and pagination support
Lightweight
No framework overhead, pure Python function with minimal dependencies
Fast Cold Start
Minimal dependencies ensure quick initialization and rapid response
Full Control
Direct access to request and response objects for complete flexibility