Enhancing a Weather Alert Application: My Journey in DevOps 🚀
Introduction
In my ongoing journey to become a proficient DevOps engineer, I recently tackled an exciting project involving a weather alert application. This experience allowed me to delve deeper into practical applications of Docker, Git, and GitHub while also learning to create a web interface for a Python script. I encountered numerous challenges along the way, but each hurdle provided invaluable learning opportunities. Here’s a detailed account of my progress and the steps I took to enhance the application.
Project Overview
The weather alert application is a simple Python script that fetches weather data for a specified city using the OpenWeatherMap API. It alerts users if the temperature or wind speed crosses set thresholds, helping them stay informed about changing weather conditions.
Key Features
Fetch Weather Data: Retrieves real-time weather information for any city.
Custom Alerts: Users can set their own temperature and wind speed thresholds for alerts.
Hourly Updates: The script checks the weather automatically every hour.
Learning and Implementation
1. Working with Docker
I practiced using Docker to containerize the application. This involved creating a Dockerfile
to define the environment and dependencies required for the application. Here’s a snippet of my Dockerfile:
# Base Image
FROM python:3.10
# Working directory
WORKDIR /app
# Code
COPY . .
# Install Libraries
RUN pip install -r requirement.txt
# Run app
CMD ["python", "main.py"]
This setup allowed me to run the application consistently across different environments, making deployment much simpler.
2. Git and GitHub Experience
After containerizing the application, I made a pull request (PR) to a public repository on GitHub. This experience was invaluable as I learned how to collaborate with other developers and contribute to open-source projects. The PR included enhancements like a web interface for the application, which I created with the help of ChatGPT.
Here's the original repository where I made the PR, and you can view my contributions here.
3. Creating a Web Interface
To make the application more user-friendly, I designed a web interface using Flask. This interface allows users to input their city name and receive alerts based on the weather data. Although I initially struggled with making it fully dynamic, I found that the web interface greatly improved user experience.
4. Overcoming Challenges
During development, I faced a specific error: an "Internal Server Error" when the user input was not handled correctly. After troubleshooting, I discovered that the Flask application needed proper error handling for user inputs, ensuring that invalid city names wouldn't cause a server crash. I implemented try-except blocks around the weather API calls, which allowed the application to return user-friendly error messages instead of breaking.
This experience emphasized the importance of robust error handling and debugging in software development. Throughout the process, I faced several other errors and roadblocks, especially while configuring the web interface and Docker environment. However, these challenges turned into learning experiences. I became adept at troubleshooting common issues and learned the importance of thorough testing and validation in my code.
Acknowledgments
I want to take a moment to thank Shubham Londhe for his invaluable guidance during the DevOps Batch-8 session, where I learned crucial concepts related to Docker, Git, and GitHub. His insights were instrumental in helping me navigate the complexities of this project.
Conclusion
This project was a significant step forward in my DevOps journey, allowing me to apply my theoretical knowledge in a practical setting. I look forward to continuing to build on these experiences and take on new challenges. If you’re interested in the weather alert application or have suggestions for improvements, feel free to check out the links above or reach out to me!
Screenshots(Output Images) :
Docker run :
Weather update of Mumbai :
Weather update of New Work :
Weather update of Australia
Subscribe to my newsletter
Read articles from Amitabh soni directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Amitabh soni
Amitabh soni
DevOps Enthusiast | Passionate Learner in Tech | BSc IT Student I’m a second-year BSc IT student with a deep love for technology and an ambitious goal: to become a DevOps expert. Currently diving into the world of automation, cloud services, and version control, I’m excited to learn and grow in this dynamic field. As I expand my knowledge, I’m eager to connect with like-minded professionals and explore opportunities to apply what I’m learning in real-world projects. Let’s connect and see how we can innovate together!