Add support for python function runtime

This commit is contained in:
Peter Stockings
2025-09-28 13:32:42 +10:00
parent 38adbd22d2
commit 99723b4b6b
4 changed files with 58 additions and 40 deletions

View File

@@ -99,6 +99,11 @@ DEFAULT_ENVIRONMENT = """{
"lines": 3
}"""
DEFAULT_PYTHON_SCRIPT = """def main(request, environment):
print(f"Method: {request['method']}")
return {"body": "Hello from Python!"}
"""
http = Blueprint('http', __name__)
@http.route("/overview", methods=["GET"])
@@ -117,9 +122,19 @@ def overview():
def new():
user_id = current_user.id
if request.method == "GET":
context = {
'user_id': user_id,
'name': 'foo',
'script': DEFAULT_SCRIPT,
'default_python_script': DEFAULT_PYTHON_SCRIPT,
'environment_info': DEFAULT_ENVIRONMENT,
'is_public': False,
'log_request': True,
'log_response': False
}
if htmx:
return render_block(environment, 'dashboard/http_functions/new.html', 'page', user_id=user_id, name='foo', script=DEFAULT_SCRIPT, environment_info=DEFAULT_ENVIRONMENT, is_public=False, log_request=True, log_response=False)
return render_template("dashboard/http_functions/new.html", user_id=user_id, name='foo', script=DEFAULT_SCRIPT, environment_info=DEFAULT_ENVIRONMENT, is_public=False, log_request=True, log_response=False)
return render_block(environment, 'dashboard/http_functions/new.html', 'page', **context)
return render_template("dashboard/http_functions/new.html", **context)
try:
name = request.json.get('name')
script_content = request.json.get('script_content')