Skip to content

Commit

Permalink
Port fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Arjan Egges committed Apr 11, 2024
1 parent f419abd commit ccf8bea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 2024/asyncio_dive/async_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def handle(

class AsyncAPIServer:
def __init__(
self, host: str = "127.0.0.1", port: int = 5000, router: Optional[Router] = None
self, host: str = "127.0.0.1", port: int = 3000, router: Optional[Router] = None
):
self.host = host
self.port = port
Expand Down
10 changes: 5 additions & 5 deletions 2024/asyncio_dive/async_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,36 @@


async def fetch_books(session: aiohttp.ClientSession) -> str:
async with session.get("http://127.0.0.1:5000/books") as response:
async with session.get("http://127.0.0.1:3000/books") as response:
return await response.text()


async def add_book(session: aiohttp.ClientSession, title: str, author: str) -> str:
async with session.post(
"http://127.0.0.1:5000/books",
"http://127.0.0.1:3000/books",
data=json.dumps({"title": title, "author": author}),
) as response:
return await response.text()


async def delete_book(session: aiohttp.ClientSession, title: str) -> str:
async with session.delete(
f"http://127.0.0.1:5000/books", data=json.dumps({"title": title})
"http://127.0.0.1:3000/books", data=json.dumps({"title": title})
) as response:
return await response.text()


async def add_movie(session: aiohttp.ClientSession, title: str, director: str) -> str:
async with session.post(
"http://127.0.0.1:5000/movies",
"http://127.0.0.1:3000/movies",
data=json.dumps({"title": title, "director": director}),
) as response:
return await response.text()


async def delete_movie(session: aiohttp.ClientSession, title: str) -> str:
async with session.delete(
f"http://127.0.0.1:5000/movies", data=json.dumps({"title": title})
"http://127.0.0.1:3000/movies", data=json.dumps({"title": title})
) as response:
return await response.text()

Expand Down

0 comments on commit ccf8bea

Please sign in to comment.