diff --git a/main.py b/main.py index 4833aa8..9aefaf7 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,14 @@ import re import traceback +from aiohttp import web import asyncpg import config import discord from discord.ext import commands +from api.main import app + initial_extensions = ( 'cogs.drive', 'cogs.events', @@ -71,7 +74,7 @@ async def on_ready(self): async def setup_hook(self): """Setup all initial requirements""" - # Setting up the database + # Connect to the database self.conn = await asyncpg.create_pool( host=config.postgres.host, database=config.postgres.database, @@ -79,6 +82,13 @@ async def setup_hook(self): password=config.postgres.password ) + # Launch the API + app['bot'] = self + runner = web.AppRunner(app) + await runner.setup() + site = web.TCPSite(runner, 'localhost', 8080) + await site.start() + # Load all the extensions for extension in initial_extensions: try: