Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Shops/household_shop/homeworks/FastApi_hw/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SERVICE_HOST = '127.0.0.1'
SERVICE_PORT = 8000

CATS_URL = 'https://meowfacts.herokuapp.com/'
DOGS_URL = 'http://dog-api.kinduff.com/api/facts'
21 changes: 21 additions & 0 deletions Shops/household_shop/homeworks/FastApi_hw/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import uvicorn
from fastapi import FastAPI
from models import Request, Response
from services import get_data, make_response
from config import SERVICE_HOST, SERVICE_PORT


app = FastAPI(title='HW_Application')


@app.post(
'/post',
description='Facts about animals',
response_model=Request,
)
async def an(test: Request):
return ...


if __name__ == "__main__":
uvicorn.run(app=app, host=SERVICE_HOST, port=SERVICE_PORT)
19 changes: 19 additions & 0 deletions Shops/household_shop/homeworks/FastApi_hw/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from enum import Enum
from pydantic import BaseModel
from typing import Tuple, Union


class Request(BaseModel):
fields: tuple[str, ...]


class CatsResponse(BaseModel):
...


class DogsResponse(BaseModel):
...


class Response(BaseModel):
data: tuple[str, ...]
12 changes: 12 additions & 0 deletions Shops/household_shop/homeworks/FastApi_hw/services.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import aiohttp
from typing import Union
from config import CATS_URL, DOGS_URL
from models import Request, Response, CurrencyInfo, WeatherReaponse


async def get_data(requset: Request) -> Response:
...


async def make_response(service_name: str) -> Union[tuple[CurrencyInfo, ...], WeatherReaponse]:
...