Packaging a few small changes
* Make edit http function endpoint accept function id rather than name * Move show alert js function to function editor template as its only used here * Added a note that previous commit (API -> isolator request was changed from global routing to inter app routing) (It sped things up, but not its regressed; need to look into this further)
This commit is contained in:
12
app.py
12
app.py
@@ -35,7 +35,8 @@ class User(UserMixin):
|
||||
return User(id=str(user_data['id']), username=user_data['username'], password_hash=user_data['password_hash'], created_at=user_data['created_at'])
|
||||
return None
|
||||
|
||||
|
||||
# Swith to inter app routing, which results in speed up from ~400ms to ~270ms
|
||||
# https://stackoverflow.com/questions/76886643/linking-two-not-exposed-dokku-apps
|
||||
API_URL = os.environ.get('API_URL', 'http://isolator.web:5000/execute') # 'https://isolator.peterstockings.com/execute' 'http://127.0.0.1:5000/execute'
|
||||
|
||||
DEFAULT_FUNCTION_NAME = 'foo'
|
||||
@@ -159,20 +160,19 @@ def get_http_function_edit_form(function_id):
|
||||
return render_block(app.jinja_env, 'dashboard/http_functions/edit.html', 'page', user_id=user_id, function_id=function_id, name=name, script=script, environment_info=environment_info, is_public=is_public, log_request=log_request, log_response=log_response)
|
||||
return render_template("dashboard/http_functions/edit.html", user_id=user_id, name=name, function_id=function_id, script=script, environment_info=environment_info, is_public=is_public, log_request=log_request, log_response=log_response)
|
||||
|
||||
@ app.route("/dashboard/http_functions/edit", methods=["POST"])
|
||||
@ app.route("/dashboard/http_functions/<int:function_id>/edit", methods=["POST"])
|
||||
@login_required
|
||||
def edit_http_function():
|
||||
def edit_http_function(function_id):
|
||||
try:
|
||||
user_id = current_user.id
|
||||
name = request.json.get('name')
|
||||
updated_name = request.json.get('updated_name')
|
||||
script_content = request.json.get('script_content')
|
||||
environment_info = request.json.get('environment_info')
|
||||
is_public = request.json.get('is_public')
|
||||
log_request = request.json.get('log_request')
|
||||
log_response = request.json.get('log_response')
|
||||
|
||||
db.edit_http_function(user_id, name, updated_name, script_content, environment_info, is_public, log_request, log_response)
|
||||
db.edit_http_function(user_id, function_id, name, script_content, environment_info, is_public, log_request, log_response)
|
||||
|
||||
return { "status": "success", "message": f'{name} updated' }
|
||||
except Exception as e:
|
||||
@@ -206,7 +206,7 @@ def get_http_function_logs(function_id):
|
||||
return render_block(app.jinja_env, 'dashboard/http_functions/logs.html', 'page', user_id=user_id, function_id=function_id, name=name, http_function_invocations=http_function_invocations)
|
||||
return render_template("dashboard/http_functions/logs.html", user_id=user_id, name=name, function_id=function_id, http_function_invocations=http_function_invocations)
|
||||
|
||||
@ app.route("/http_functions/<int:function_id>/client", methods=["GET"])
|
||||
@ app.route("/dashboard/http_functions/<int:function_id>/client", methods=["GET"])
|
||||
@login_required
|
||||
def client(function_id):
|
||||
user_id = current_user.id
|
||||
|
||||
Reference in New Issue
Block a user