Main page of booking platform can be reached
This commit is contained in:
parent
190d4d2a4b
commit
95e313d922
7 changed files with 571 additions and 3 deletions
|
@ -1,9 +1,21 @@
|
|||
import asyncio
|
||||
import logging
|
||||
|
||||
from aiohttp import ClientResponse
|
||||
|
||||
from resa_padel import config
|
||||
from resa_padel.gestion_sports_connector import GestionSportsConnector
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def main():
|
||||
LOGGER.info("Starting booking padel court")
|
||||
async def connect(url: str) -> ClientResponse:
|
||||
booking_platform = GestionSportsConnector(url)
|
||||
return await booking_platform.connect()
|
||||
|
||||
|
||||
def main() -> ClientResponse:
|
||||
LOGGER.info("Starting booking padel court")
|
||||
response = asyncio.run(connect(config.GESTION_SPORTS_URL))
|
||||
LOGGER.info("Finished booking padel court")
|
||||
return response
|
||||
|
|
|
@ -11,3 +11,6 @@ def init_log_config():
|
|||
with open(logging_file, "r") as f:
|
||||
logging_config = yaml.safe_load(f.read())
|
||||
logging.config.dictConfig(logging_config)
|
||||
|
||||
|
||||
GESTION_SPORTS_URL = "https://toulousepadelclub.gestion-sports.com"
|
||||
|
|
22
resa_padel/gestion_sports_connector.py
Normal file
22
resa_padel/gestion_sports_connector.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
import logging
|
||||
|
||||
from aiohttp import ClientSession, ClientResponse
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class GestionSportsConnector:
|
||||
|
||||
def __init__(self, url: str):
|
||||
LOGGER.info("Initializing connection to GestionSports API")
|
||||
self.url = url
|
||||
self.session = ClientSession()
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
self.session.close()
|
||||
|
||||
async def connect(self) -> ClientResponse:
|
||||
LOGGER.info("Connecting to GestionSports API")
|
||||
async with self.session.get(self.url) as response:
|
||||
await response.text()
|
||||
return response
|
Loading…
Add table
Add a link
Reference in a new issue