diff options
| author | Abdellah El Morabit <nsrddyn@gmail.com> | 2024-11-24 12:41:38 +0100 |
|---|---|---|
| committer | Abdellah El Morabit <nsrddyn@gmail.com> | 2024-11-24 12:41:38 +0100 |
| commit | 3a6928a0189bfe8d481c7eeac7a3d3df5dd9cdc0 (patch) | |
| tree | 86a00bcd10dae82ac566e68c2c525fa71a44607a /templates/api.py | |
| parent | 567787eabe414592d005c727868091bcba2bf6fe (diff) | |
updates to the web gui
Diffstat (limited to 'templates/api.py')
| -rw-r--r-- | templates/api.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/templates/api.py b/templates/api.py new file mode 100644 index 0000000..b04ef77 --- /dev/null +++ b/templates/api.py | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | from flask import Flask, request, jsonify, render_template | ||
| 2 | |||
| 3 | app = Flask(__name__) | ||
| 4 | |||
| 5 | |||
| 6 | @app.route("/") | ||
| 7 | def index(): | ||
| 8 | return render_template("index.html") | ||
| 9 | |||
| 10 | |||
| 11 | @app.route("/api/run-script", methods=["POST"]) | ||
| 12 | def run_script(): | ||
| 13 | data = request.json | ||
| 14 | if not data: | ||
| 15 | return jsonify({"error": "No data provided"}), 400 | ||
| 16 | |||
| 17 | script_result = my_script_logic(data.get("input")) | ||
| 18 | |||
| 19 | return jsonify({"result": script_result}) | ||
| 20 | |||
| 21 | |||
| 22 | def my_script_logic(input_value): | ||
| 23 | return f"Processed input: {input_value}" | ||
| 24 | |||
| 25 | |||
| 26 | if __name__ == "__main__": | ||
| 27 | app.run(host="0.0.0.0", port=5000, debug=True) | ||
