webui progress/added alerts
This commit is contained in:
parent
d94163e246
commit
5cd502b19c
4 changed files with 23 additions and 5 deletions
|
|
@ -1,4 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
||||
<style>
|
||||
body {
|
||||
background-color: #333;
|
||||
|
|
@ -56,6 +58,16 @@
|
|||
<br>
|
||||
{% endfor %}
|
||||
<button type="submit">Submit</button>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="alert alert-success">
|
||||
{{ message }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -2,6 +2,7 @@ import asyncio
|
|||
import discord
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from dotenv import load_dotenv
|
||||
from src.bot import bot
|
||||
from src.webui import flask_app
|
||||
|
|
@ -12,11 +13,14 @@ def run_flask_app(process):
|
|||
if not flask_port:
|
||||
flask_port = '5000'
|
||||
flask_app.bot_process = process
|
||||
flask_app.secret_key = "woaoaoahaowhawoiahoahhhhhh"
|
||||
flask_app.run(debug=True, use_reloader=False ,host='0.0.0.0', port=flask_port)
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
load_dotenv()
|
||||
process = subprocess.Popen(["python", "sparkytron3000.py"])
|
||||
process = subprocess.Popen([sys.executable, "sparkytron3000.py"])
|
||||
run_flask_app(process)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue