diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..82eae7c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Use an official Python runtime as a parent image +FROM python:3.8 +MAINTAINER label="Rohan Rustagi" +# Set the working directory in the container +WORKDIR /app + +# Copy your Python script into the container +COPY *.py . + +# Install the required dependencies (in this case, the ozon3 library) +RUN pip install ozon3 + +# Define the command to run your Python script +CMD ["python", "myapi.py"] diff --git a/README.md b/README.md index f4d12cb..6ab6205 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,30 @@ data = o3.get_historical_data(city='Houston') # data from 2014 onwards! ![Gif of Ozon3.get_multiple_city_air()](/src/media/example_get_multiple_city_air.gif) ![Gif of Ozon3.get_historical_data()](/src/media/example_get_historical_data.gif) + +### Steps to use Docker for the Application + + +Screenshot 2023-11-05 at 11 58 03 PM + + +```shell +docker build -t . +``` + +* `Single City`: For Fetching All details of city (eg. London, HongKong, Paris, Delhi, etc) + +```shell +docker run python getcityair.py +``` + + +* `Specific Parameter`: For Fetching Specific detail of city, For parameter please refer below values (eg. aqi, pm2.5, dew, etc) + +```shell +docker run python getspecificparam.py +``` + ### Air Quality Parameters Ozon3 can fetch the following parameters: diff --git a/getcityair.py b/getcityair.py new file mode 100644 index 0000000..d26947f --- /dev/null +++ b/getcityair.py @@ -0,0 +1,22 @@ +import sys +import ozon3 as ooo + +# Check if the city is provided as a command-line argument +if len(sys.argv) != 2: + print("Usage: python getcityair.py ") + sys.exit(1) + +# Get the city from the command-line argument +city = sys.argv[1] + +o3 = ooo.Ozon3('YOUR_TOKEN') + +try: + # Fetch air quality data for the specified city + data = o3.get_city_air(city) + print(data) + +except Exception as e: + print(f"Error: {str(e)}") + + diff --git a/getspecificparam.py b/getspecificparam.py new file mode 100644 index 0000000..af023fc --- /dev/null +++ b/getspecificparam.py @@ -0,0 +1,32 @@ +import sys +import ozon3 as ooo + +# Define a function to get a specific parameter for a given city +def get_specific_parameter(city, parameter): + o3 = ooo.Ozon3('YOUR_TOKEN') + + try: + # Fetch air quality data for the specified city + data = o3.get_city_air(city) + + # Check if the parameter exists in the data + if parameter in data: + return data[parameter] + else: + return f"Parameter '{parameter}' not found in the data." + + except Exception as e: + return f"Error: {str(e)}" + +# Check if the city and parameter are provided as command-line arguments +if len(sys.argv) != 3: + print("Usage: python getspecificparam.py ") + sys.exit(1) + +# Get the city and parameter from the command-line arguments +city = sys.argv[1] +parameter = sys.argv[2] + +result = get_specific_parameter(city, parameter) +print(result) + diff --git a/requirements.txt b/requirements.txt index 8acfcbb..e805613 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,6 +10,8 @@ mypy flake8 black pre-commit +ozon3 +flask pytest==7.1.1 pytest-cov==4.0.0