diff --git a/__pycache__/config.cpython-311.pyc b/__pycache__/config.cpython-311.pyc new file mode 100644 index 0000000..8d3c317 Binary files /dev/null and b/__pycache__/config.cpython-311.pyc differ diff --git a/app.py b/app.py index 78f33ba..3b35d8d 100644 --- a/app.py +++ b/app.py @@ -3,22 +3,11 @@ import os from flask import Flask, render_template, request, redirect, url_for from flask_socketio import SocketIO +from config import * + app = Flask(__name__) socketio = SocketIO(app) -FILE_PATH = '/data/interface/fichier.txt' - -class path: - ansible_scripts = '/data/Ansible-Playbook/' - default_hosts = '/data/Ansible-Playbook/hosts' - binary = '/usr/bin/ansible-playbook ' - -class flask_config: - port=8000 - host='0.0.0.0' - thread=True - debug=False - @app.route('/') def index(): playbooks=[] @@ -33,19 +22,16 @@ def edit(): FILE_PATH = path.ansible_scripts+request.form['file_edit'] with open(FILE_PATH, 'r') as file: file_content = file.read() - return render_template('edit_file.html', file_content=file_content, filepath=FILE_PATH) + return render_template('edit_file.html', file_content=file_content, filepath=FILE_PATH,file_name=request.form['file_edit']) @app.route('/edit_file', methods=['POST']) def edit_file(): new_content = request.form.get('file_content') FILE_PATH = request.form.get('file_path') - print("edit "+FILE_PATH) - with open(FILE_PATH, 'w') as file: file.write(new_content) return redirect(url_for('index')) - @app.route('/run') def run(): return render_template('run.html') diff --git a/config.py b/config.py new file mode 100644 index 0000000..d31aa58 --- /dev/null +++ b/config.py @@ -0,0 +1,17 @@ +''' +ansible_scripts : location of the playbooks +default_hosts: default hosts file path +binary : ansible binary path (use "whereis ansible-playbook" to find it) +''' + +class path: + ansible_scripts = '/data/Ansible-Playbook/' + default_hosts = '/data/Ansible-Playbook/hosts' + binary = '/usr/bin/ansible-playbook ' + +class flask_config: + port=8000 + host='0.0.0.0' + thread=True + debug=False + diff --git a/static/style.css b/static/style.css index c73299b..9e1fb12 100644 --- a/static/style.css +++ b/static/style.css @@ -6,3 +6,7 @@ padding-top: 10px; border-color:#ccc; } +.notes { + font-style: italic; + font-size: xs-small; +} diff --git a/templates/base.html b/templates/base.html index 9bb0d9b..f303623 100644 --- a/templates/base.html +++ b/templates/base.html @@ -14,7 +14,10 @@
+