webui progress/added alerts

This commit is contained in:
phixxy 2024-06-18 22:59:30 -07:00
parent d94163e246
commit 5cd502b19c
4 changed files with 23 additions and 5 deletions

View file

@ -26,7 +26,7 @@ async def on_ready():
await utils.delete_all_files("tmp/")
await load_cogs(bot, 'cogs/')
logger.info('We have logged in as {0.user}'.format(bot))
print("Visit http://localhost:5000 to change config!")
print("If using the webui, visit http://localhost:5000 to change config!")
except:
logger.warning(f"Error in on_ready")

View file

@ -1,8 +1,9 @@
import logging
import os
import subprocess
import sys
from flask import Flask, render_template, request
from flask import Flask, render_template, request, flash
logger = logging.getLogger("bot")
flask_app = Flask(__name__, template_folder='../flask_templates')
@ -39,7 +40,8 @@ async def index():
file.write(f"{key}='{value}'\n")
print(form_dict)
flask_app.bot_process.terminate()
flask_app.bot_process = subprocess.Popen(["python", "sparkytron3000.py"])
return 'Your input has been saved! The bot must be restarted for the changes to take effect.'
flask_app.bot_process = subprocess.Popen([sys.executable, "sparkytron3000.py"])
message = "Variables Updated!"
flash(message)
return render_template('index.html', key_value_pairs = key_value_pairs)