diff --git a/app.py b/app.py index 56215da..c35ea86 100644 --- a/app.py +++ b/app.py @@ -60,6 +60,10 @@ def index(): def client(): return render_template("client.html") +@ app.route("/dashboard", methods=["GET"]) +def dashboard(): + return render_template("dashboard.html") + @app.route('/execute', methods=['POST']) def execute_code(): @@ -89,6 +93,47 @@ def execute_code(): except Exception as e: return jsonify({'error': str(e)}), 500 + +@app.route('/f/', methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD']) +def execute_http_function(function): + try: + # TODO: Get code from database based on function name + code = DEFAULT_SCRIPT + + request_obj = { + 'method': request.method, + 'headers': dict(request.headers), + 'url': request.url, + # Add other request properties as needed + } + + # Add JSON data if it exists + if request.is_json: + request_obj['json'] = request.get_json() + + # Add form data if it exists + if request.form: + request_obj['form'] = request.form.to_dict() + + # Add query parameters if they exist + if request.args: + request_obj['query'] = request.args.to_dict() + + # Add plain text data if it exists + if request.data and not request.is_json: + request_obj['text'] = request.data.decode('utf-8') + + # Call the Node.js API + response = requests.post(API_URL, json={'code': code, 'request': request_obj}) + response_data = response.json() + + # Map the Node.js response to Flask response + flask_response = map_isolator_response_to_flask_response(response_data) + return flask_response + + + except Exception as e: + return jsonify({'error': str(e)}), 500 if __name__ == '__main__': diff --git a/templates/dashboard.html b/templates/dashboard.html new file mode 100644 index 0000000..27fc0ec --- /dev/null +++ b/templates/dashboard.html @@ -0,0 +1,152 @@ +{% extends 'base.html' %} + +{% block content %} + +
+ +
+
+ + Home +
+
+
+ + +
+
+
+
+
+
+

HTTP functions

+
+
+
+ + + + + + + + + + + + + + + +
Name
HelloWorld
+
+
+
+
+
+ + +{% endblock %} \ No newline at end of file