Help Center/ FunctionGraph/ Developer Guide/ Python/ Python Function Template
Updated on 2025-12-10 GMT+08:00

Python Function Template

Python Function

The following is a sample code template of a Python function:

# -*- coding:utf-8 -*-
import json
def handler (event, context):
    return {
        "statusCode": 200,
        "isBase64Encoded": False,
        "body": json.dumps(event),
        "headers": {
            "Content-Type": "application/json"
        }
    }

When you create an empty Python event function on the FunctionGraph console, the preceding sample code is deployed by default.