函数工作流 FUNCTIONGRAPH-示例2:上传代码到OBS桶,并使用OBS链接创建函数:步骤1:创建函数工程

时间:2025-05-28 09:46:56

步骤1:创建函数工程

  1. 编写打印helloworld的代码。

    打开文本编辑器,编写helloworld函数,代码如下,文件命名为“helloworld.py”,保存文件。

    def printhello(): 
        print 'Hello world!' 
  2. 定义FunctionGraph函数。

    打开文本编辑器,定义函数,代码如下,文件命名为“index.py”,保存文件(与“helloworld.py”保存在同一文件夹下)。

    import json 
    import helloworld 
     
    def handler (event, context): 
        output =json.dumps(event) 
        helloworld.printhello() 
        return output
support.huaweicloud.com/api-functiongraph/functiongraph_06_0204.html
提示

您即将访问非华为云网站,请注意账号财产安全