From aac485401bad467e930c1944639ca2d6d48215c6 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 19 Dec 2023 13:48:06 +0100 Subject: [PATCH] Refonte --- __pycache__/config.cpython-311.pyc | Bin 0 -> 965 bytes app.py | 20 +++----------------- config.py | 17 +++++++++++++++++ static/style.css | 4 ++++ templates/base.html | 3 +++ templates/edit_file.html | 13 +++++++++---- templates/index.html | 20 ++++++++++++++++---- templates/run.html | 3 ++- 8 files changed, 54 insertions(+), 26 deletions(-) create mode 100644 __pycache__/config.cpython-311.pyc create mode 100644 config.py diff --git a/__pycache__/config.cpython-311.pyc b/__pycache__/config.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8d3c3179a7c51b7dea35b44a02eb87f06738ff46 GIT binary patch literal 965 zcmZ`%y>HYo6n8!@InqmEs6eXtuqr?VsSRSRPz6hwIFMkb(o7x3a_o)L9P_CP)dq*{h9=>YLQuH% zX-qjyMR#Jmdt?hrrXuA8rZVv2t`t2hCF-%5Ij^Fhi&%fxxr!JRDFbUd_)ndJcN!IDU^1o z8X)wsz*)=OToJYMFDX|!jUGS2QWtb~A)j1Qp5T~Gz zg}kT1QJ@58TvoOguyW*>Q%tHJp`+q}>rQTR8fb651HBSk3NBRRu9Xkx?kxp3{POX< z@0X9XHP`jcVPI7*LWIQ#HNw>KF28Zsf6@GxJ-(st=(Z85f`w%m#=^7>djT{IEaT|{ a{0}F3@AMzx*~YrQu?i=8@AL|y&i5~vZTJ2F literal 0 HcmV?d00001 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 @@ +Ansinterface +

Ansinterface

+

{% block content %}{% endblock %}