Add flask config
This commit is contained in:
parent
4f220a5c17
commit
dcd4fd6026
|
@ -621,7 +621,7 @@ class PrepareRoomView(disnake.ui.View):
|
|||
def run():
|
||||
config = Config.load()
|
||||
|
||||
http.run_web_server()
|
||||
http.run_web_server(config)
|
||||
|
||||
logger = logging.getLogger('discord')
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
|
|
@ -28,6 +28,9 @@ class Config:
|
|||
brother_channel: int = None
|
||||
brother_channel_webhook: int = None
|
||||
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
|
||||
def load(cls, filename: str | None = None) -> "Config":
|
||||
|
|
|
@ -2,6 +2,7 @@ from threading import Thread
|
|||
|
||||
from flask import Flask, render_template
|
||||
|
||||
from orochi.config import Config
|
||||
from orochi.models import Game
|
||||
|
||||
app = Flask(__name__)
|
||||
|
@ -19,5 +20,8 @@ def admin():
|
|||
return render_template('list.html', game=game, admin=True)
|
||||
|
||||
|
||||
def run_web_server():
|
||||
Thread(target=lambda: app.run(debug=True, use_reloader=False)).start()
|
||||
def run_web_server(config: Config):
|
||||
Thread(target=lambda: app.run(host=config.http_host,
|
||||
port=config.http_port,
|
||||
debug=config.http_debug,
|
||||
use_reloader=False)).start()
|
||||
|
|
Loading…
Reference in New Issue