Skip to main content

Execution Environment

Cloud functions execute in a secure Python environment with access to these pre-injected globals — no imports needed:

Request Object (req)

Database (db)

HTTP Client (http)

Authentication (auth)

Template Rendering (render)

Module System (use())

Queue (queue)

Configuration (config)

Available Standard Library Modules

  • json — JSON encoding/decoding
  • datetime, timedelta — Date and time
  • math — Mathematical functions
  • re — Regular expressions
  • random — Random number generation
  • secrets — Cryptographically secure random
  • time — Time utilities
  • hashlib — Hash functions
  • uuid — UUID generation
  • base64 — Base64 encoding/decoding
  • urllib — URL parsing
  • collections — Counter, defaultdict
  • itertools — Iterator functions
  • functools — Higher-order functions
  • decimal — Decimal precision
  • statistics — Statistical functions
  • dataclasses — Dataclasses

WebSocket Globals

WebSocket functions have additional objects:

Security & Sandboxing

Not available in cloud functions:
  • File system access (open, os.listdir)
  • System commands (os.system, subprocess)
  • Network sockets (use http instead)
  • Process manipulation
Available:
  • Safe built-ins (len, str, int, dict etc.)
  • Standard library modules listed above
  • HTTP requests via http object
  • Database access via db object

Timeouts

Best Practices