in marketing-analytics/activation/sheets-based-installer/src/apps_script/2_base/colab_solution.js [122:161]
getMainFile() {
return `# Copyright 2023 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import flask
import inspect
import functions_framework
import ${PUPA_COLAB_PACKAGE}
@functions_framework.http
def ${PUPA_PROXY_FUNCTION_NAME}(request: flask.Request) -> flask.typing.ResponseReturnValue:
request_json = request.get_json(silent=True)
if request_json and "args" in request_json:
if "vars" in request_json:
for key in request_json["vars"]:
setattr(${PUPA_COLAB_PACKAGE}, key , request_json["vars"][key])
if "functionName" in request_json:
functionName = request_json["functionName"]
fn = getattr(${PUPA_COLAB_PACKAGE}, functionName)
else:
functions = inspect.getmembers(${PUPA_COLAB_PACKAGE}, predicate=inspect.isfunction)
if(len(functions) > 1):
return "Unspecified function name", 400
fn = functions[0][1]
return {"result": fn(*request_json["args"])}
else:
return "Bad request", 400
`
}