Add flask config

This commit is contained in:
Yohann D'ANELLO 2021-11-13 15:54:59 +01:00
parent 4f220a5c17
commit dcd4fd6026
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
3 changed files with 10 additions and 3 deletions

View File

@ -621,7 +621,7 @@ class PrepareRoomView(disnake.ui.View):
def run(): def run():
config = Config.load() config = Config.load()
http.run_web_server() http.run_web_server(config)
logger = logging.getLogger('discord') logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)

View File

@ -28,6 +28,9 @@ class Config:
brother_channel: int = None brother_channel: int = None
brother_channel_webhook: int = None brother_channel_webhook: int = None
player_roles: dict[str, int] = field(default_factory=dict) player_roles: dict[str, int] = field(default_factory=dict)
http_host: str = '127.0.0.1'
http_port: int = 5000
http_debug: bool = True
@classmethod @classmethod
def load(cls, filename: str | None = None) -> "Config": def load(cls, filename: str | None = None) -> "Config":

View File

@ -2,6 +2,7 @@ from threading import Thread
from flask import Flask, render_template from flask import Flask, render_template
from orochi.config import Config
from orochi.models import Game from orochi.models import Game
app = Flask(__name__) app = Flask(__name__)
@ -19,5 +20,8 @@ def admin():
return render_template('list.html', game=game, admin=True) return render_template('list.html', game=game, admin=True)
def run_web_server(): def run_web_server(config: Config):
Thread(target=lambda: app.run(debug=True, use_reloader=False)).start() Thread(target=lambda: app.run(host=config.http_host,
port=config.http_port,
debug=config.http_debug,
use_reloader=False)).start()