This application is designed to monitor weather data, utilizing the OpenWeatherMap API to retrieve weather information and store it in a MongoDB database. It provides a RESTful API to interact with the data and a simple user interface to display weather information.
- Fetch current weather data from the OpenWeatherMap API.
- Store weather data in a MongoDB database.
- Calculate daily weather summaries.
- Trigger alerts based on user-defined thresholds.
- User-friendly interface for viewing weather data.
- Python: The primary programming language.
- Flask: Web framework for building the API.
- MongoDB: NoSQL database for storing weather data.
- Requests: For making API calls to OpenWeatherMap.
- Python: Ensure Python is installed on your machine. You can download it from Python's official website.
- MongoDB: Make sure you have a MongoDB instance running. You can download MongoDB from MongoDB's official website.
-
Create a
.envfile in the root directory of your project with the following content:OPENWEATHER_API_KEY=your_api_key_here MONGODB_URI=mongodb://localhost:27017/weatherdbReplace
your_api_key_herewith your actual OpenWeatherMap API key. -
Install the required Python packages:
pip install -r requirements.txt
-
Run the application:
python app.py
-
Access the application at
http://localhost:5000.
To set up and run the application, the following dependencies are required:
- Flask: For building the web server and API.
- Requests: For making API calls to OpenWeatherMap.
- PyMongo: For interacting with the MongoDB database.
These dependencies are listed in the requirements.txt file.
To run the tests, use the following command:
pytest test_app.py