Skip to main content

xiliu Aliyun FunctionCompute SDK2

Project description

https://badge.fury.io/py/aliyun-fc2.svg https://travis-ci.org/aliyun/fc-python-sdk.svg?branch=master https://coveralls.io/repos/github/aliyun/fc-python-sdk/badge.svg?branch=master

Overview

The SDK of this version is dependent on the third-party HTTP library requests.

Running environment

Python 3.6+

Installation

Install the official release version through PIP (taking Linux as an example):

$ pip install xl-aliyun-fc2

You can also install the unzipped installer package directly:

$ sudo python setup.py install

Getting started

# -*- coding: utf-8 -*-
import fc2
import zipfile
import base64

# To know the endpoint and access key id/secret info, please refer to:
# https://help.aliyun.com/document_detail/52984.html
client = fc2.Client(
    endpoint='<Your Endpoint>',
    accessKeyID='<Your AccessKeyID>',
    accessKeySecret='<Your AccessKeySecret>')

# Create service.
client.create_service('demo')

zipFileBase64 = ''
with open('file.zip', 'rb') as f:
    content = f.read()
    zipFileBase64 = base64.b64encode(content).decode()

# Create function.
client.create_function('demo',
    {
        'functionName':'test_func',
        'runtime': 'python3',
        'handler': 'index.handler',
        'code': {
            'zipFile': zipFileBase64
        },
        'environmentVariables': {'testKey': 'testValue'}
    }
)

# Invoke function synchronously.
client.invoke_function('demo', 'test_func')

More resources

Contacting us

License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xl-aliyun-fc2-0.0.2.tar.gz (14.2 kB view hashes)

Uploaded Source

Built Distribution

xl_aliyun_fc2-0.0.2-py3-none-any.whl (14.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page