Made web ui into a cog it doesnt work yet but it doesnt throw errors. All pages are 404. Tho the web responds to get calls wich is good
parent
63d82f5785
commit
6d8c1c066a
@ -0,0 +1,14 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
class Greetings(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.slash_command(guild_ids=["823188238260633600"])
|
||||
async def hello(self, ctx):
|
||||
await ctx.send(f'Hello {ctx.author}')
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Greetings(bot))
|
||||
|
Binary file not shown.
@ -0,0 +1,13 @@
|
||||
#The webserver plugin cofiguration file.
|
||||
[webserver]
|
||||
#This will specify the ip adress of the machine that the server is running on. I would recomend to change it as some pages might 404 if you dont.
|
||||
ip=0.0.0.0
|
||||
|
||||
#The port to listen on.
|
||||
port=5000
|
||||
|
||||
#Section related to security and .key, .crt file locations. Its really recomended to use ssl if you are exposing the web interface to the internet.
|
||||
[SSL]
|
||||
userssl=False
|
||||
crt="certs/certificate.crt"
|
||||
key="certs/private.key"
|
@ -0,0 +1,37 @@
|
||||
import sys
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import quart
|
||||
import toml
|
||||
import logging
|
||||
|
||||
class WebServer(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.app = quart.Quart(__name__)
|
||||
|
||||
with open("config.toml", "r") as f:
|
||||
config = toml.load(f)
|
||||
|
||||
logging.info("Starting Quart server...")
|
||||
bot.loop.create_task(self.app.run_task(config["webserver"]["ip"], config["webserver"]["port"]))
|
||||
|
||||
@self.app.route('/', methods=['GET'])
|
||||
async def index():
|
||||
return await render_template('index.html')
|
||||
|
||||
@self.app.route('/configuration', methods=['GET'])
|
||||
async def configuration():
|
||||
return await render_template('configuration.html')
|
||||
|
||||
@self.app.route('/dashboard', methods=['GET'])
|
||||
async def dashboard():
|
||||
return await render_template('dashboard.html')
|
||||
|
||||
@self.app.route('/plugins', methods=['GET'])
|
||||
async def plugins():
|
||||
return await render_template('plugins.html')
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(WebServer(bot))
|
||||
|
Loading…
Reference in New Issue