Fetch http_functions from database

This commit is contained in:
Peter Stockings
2023-12-16 19:02:04 +11:00
parent 4796b7d8d1
commit e88661dfd2
5 changed files with 99 additions and 8 deletions

18
services.py Normal file
View File

@@ -0,0 +1,18 @@
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']
}
view_model.append(function_view_model)
return view_model