This commit is contained in:
root
2023-12-19 13:48:06 +01:00
parent 8ea55ac5e2
commit aac485401b
8 changed files with 54 additions and 26 deletions
+3 -17
View File
@@ -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')