Add ability to test http functions with postman like interface

This commit is contained in:
Peter Stockings
2023-12-16 19:55:51 +11:00
parent 8f94ae12ef
commit ab25d557f8
5 changed files with 86 additions and 96 deletions

View File

@@ -1,18 +1,25 @@
def create_http_function_view_model(http_function):
# Base URL for the function invocation
base_url = "https://function.peterstockings.com/f/"
name = http_function['name']
function_view_model = {
"id": http_function['id'],
"name": name,
"script_content": http_function['script_content'],
"url": f"{base_url}{name}",
"invoke_count": http_function['invoked_count']
}
return function_view_model
def create_http_functions_view_model(http_functions):
# Base URL for the function invocation
base_url = "https://function.peterstockings.com/f/"
view_model = []
for function in http_functions:
name = function['name']
function_view_model = {
"id": function['id'],
"name": name,
"script_content": function['script_content'],
"url": f"{base_url}{name}",
"invoke_count": function['invoked_count']
}
function_view_model = create_http_function_view_model(function)
view_model.append(function_view_model)
return view_model