understanding's picture
Create bot/server/init.py
0e30fc4 verified
raw
history blame
704 Bytes
from quart import Quart
from uvicorn import Server as UvicornServer, Config
from logging import getLogger
from bot.config import Server as S
from bot import LOGGER_CONFIG_JSON
from . import main
logger = getLogger("uvicorn")
instance = Quart(__name__)
instance.config["RESPONSE_TIMEOUT"] = None
instance.config["MAX_CONTENT_LENGTH"] = 999999999999999
@instance.before_serving
async def before_serve():
logger.info("Web server is started!")
logger.info(f"Server running on {S.BIND_ADDRESS}:{S.PORT}")
instance.register_blueprint(main.bp)
server = UvicornServer(
Config(
app=instance,
host=S.BIND_ADDRESS,
port=S.PORT,
log_config=LOGGER_CONFIG_JSON,
)
)