-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created Dockerfile & Python File for the Application #175
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wouldn't scale well with projects as they grow, as it indiscriminately copies all files from the build context into the docker image |
||
|
||
# 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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <city>") | ||
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)}") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <city> <parameter>") | ||
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ mypy | |
flake8 | ||
black | ||
pre-commit | ||
ozon3 | ||
flask | ||
|
||
pytest==7.1.1 | ||
pytest-cov==4.0.0 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LABEL maintainer="Rohan Rustagi" would be the modern way to write this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback.