Change function name to path so you can pass in sub paths to executing code
This commit is contained in:
13
app.py
13
app.py
@@ -227,10 +227,15 @@ def execute_code():
|
||||
except Exception as e:
|
||||
return jsonify({'error': str(e)}), 500
|
||||
|
||||
@app.route('/f/<int:user_id>/<function>', methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD'])
|
||||
@app.route('/f/<int:user_id>/<path:function>', methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD'])
|
||||
def execute_http_function(user_id, function):
|
||||
try:
|
||||
http_function = db.get_http_function(user_id, function)
|
||||
# Split the function_path into the function name and the sub-path
|
||||
parts = function.split('/', 1)
|
||||
function_name = parts[0]
|
||||
sub_path = '/' + parts[1] if len(parts) > 1 else '/'
|
||||
|
||||
http_function = db.get_http_function(user_id, function_name)
|
||||
if not http_function:
|
||||
return jsonify({'error': 'Function not found'}), 404
|
||||
|
||||
@@ -252,7 +257,7 @@ def execute_http_function(user_id, function):
|
||||
'method': request.method,
|
||||
'headers': dict(request.headers),
|
||||
'url': request.url,
|
||||
# Add other request properties as needed
|
||||
'path': sub_path,
|
||||
}
|
||||
|
||||
# Add JSON data if it exists
|
||||
@@ -275,7 +280,7 @@ def execute_http_function(user_id, function):
|
||||
response = requests.post(API_URL, json={'code': code, 'request': request_data, 'environment': environment})
|
||||
response_data = response.json()
|
||||
|
||||
db.update_http_function_environment_info_and_invoked_count(user_id, function, response_data['environment'])
|
||||
db.update_http_function_environment_info_and_invoked_count(user_id, function_name, response_data['environment'])
|
||||
db.add_http_function_invocation(
|
||||
http_function['id'],
|
||||
response_data['status'],
|
||||
|
||||
Reference in New Issue
Block a user