Skip to content

Commit

Permalink
Launch API on localhost:8080
Browse files Browse the repository at this point in the history
  • Loading branch information
GetPsyched committed Apr 3, 2022
1 parent 25eead6 commit a34d752
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -71,14 +74,21 @@ 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,
user=config.postgres.user,
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:
Expand Down

0 comments on commit a34d752

Please sign in to comment.