Spaces:
Runtime error
Runtime error
Create bot/server/init.py
Browse files- bot/server/init.py +28 -0
bot/server/init.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from quart import Quart
|
| 2 |
+
from uvicorn import Server as UvicornServer, Config
|
| 3 |
+
from logging import getLogger
|
| 4 |
+
from bot.config import Server as S
|
| 5 |
+
from bot import LOGGER_CONFIG_JSON
|
| 6 |
+
from . import main
|
| 7 |
+
|
| 8 |
+
logger = getLogger("uvicorn")
|
| 9 |
+
|
| 10 |
+
instance = Quart(__name__)
|
| 11 |
+
instance.config["RESPONSE_TIMEOUT"] = None
|
| 12 |
+
instance.config["MAX_CONTENT_LENGTH"] = 999999999999999
|
| 13 |
+
|
| 14 |
+
@instance.before_serving
|
| 15 |
+
async def before_serve():
|
| 16 |
+
logger.info("Web server is started!")
|
| 17 |
+
logger.info(f"Server running on {S.BIND_ADDRESS}:{S.PORT}")
|
| 18 |
+
|
| 19 |
+
instance.register_blueprint(main.bp)
|
| 20 |
+
|
| 21 |
+
server = UvicornServer(
|
| 22 |
+
Config(
|
| 23 |
+
app=instance,
|
| 24 |
+
host=S.BIND_ADDRESS,
|
| 25 |
+
port=S.PORT,
|
| 26 |
+
log_config=LOGGER_CONFIG_JSON,
|
| 27 |
+
)
|
| 28 |
+
)
|