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

时间:2023-11-01 16:25:44

步骤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