Download bot/server/__init__.py from dimag69/tg-fs: direct link, hf CLI and curl.
- Browser
- Download file 898 Bytes
-
https://huggingface.co/spaces/dimag69/tg-fs/resolve/main/bot/server/__init__.py
- Command line
-
hf download hf://spaces/dimag69/tg-fs/bot/server/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/dimag69/tg-fs/resolve/main/bot/server/__init__.py
898 Bytes
| from quart import Quart | |
| from uvicorn import Server as UvicornServer, Config | |
| from logging import getLogger | |
| from bot.config import Server, LOGGER_CONFIG_JSON | |
| from . import main, error | |
| logger = getLogger('uvicorn') | |
| instance = Quart(__name__) | |
| instance.config['RESPONSE_TIMEOUT'] = None | |
| async def before_serve(): | |
| logger.info('Web server is started!') | |
| logger.info(f'Server running on {Server.BIND_ADDRESS}:{Server.PORT}') | |
| instance.register_blueprint(main.bp) | |
| instance.register_error_handler(400, error.invalid_request) | |
| instance.register_error_handler(404, error.not_found) | |
| instance.register_error_handler(405, error.invalid_method) | |
| instance.register_error_handler(error.HTTPError, error.http_error) | |
| server = UvicornServer ( | |
| Config ( | |
| app=instance, | |
| host=Server.BIND_ADDRESS, | |
| port=Server.PORT, | |
| log_config=LOGGER_CONFIG_JSON | |
| ) | |
| ) | |