Refonte
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user