Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amanmandal-m/weather_data_tdd_flask
This project implements a simple Flask-based backend API for weather data. It allows users to retrieve weather information for specific cities, add new weather data, update existing weather data, and delete weather data for a city.
https://github.com/amanmandal-m/weather_data_tdd_flask
flask pytest python render
Last synced: about 8 hours ago
JSON representation
This project implements a simple Flask-based backend API for weather data. It allows users to retrieve weather information for specific cities, add new weather data, update existing weather data, and delete weather data for a city.
- Host: GitHub
- URL: https://github.com/amanmandal-m/weather_data_tdd_flask
- Owner: Amanmandal-M
- Created: 2023-07-09T21:05:55.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-07-12T17:50:06.000Z (over 1 year ago)
- Last Synced: 2024-04-09T14:57:36.769Z (7 months ago)
- Topics: flask, pytest, python, render
- Language: Python
- Homepage: https://weather-backend-api-zne0.onrender.com/
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Weather Backend API
This project implements a simple Flask-based backend API for weather data. It allows users to retrieve weather information for specific cities, add new weather data, update existing weather data, and delete weather data for a city.
## Project Structure
The project follows the following folder structure:
- `app.py`: The main Flask application file. It initializes the Flask app, registers routes, and starts the server.
- `routes/weather_routes.py`: Defines the routes for weather data operations.
- `controllers/weather_controllers.py`: Contains the controller functions for handling weather data operations.
- `tests/weather_test.py`: Contains test cases to verify the functionality of the API endpoints.## Usage
1. Start the server by running the `app.py` file.
2. Access the API endpoints using the following routes:- `GET /weather-api/weather/`: Retrieve weather data for a specific city.
- `POST /weather-api/weather`: Add new weather data for a city.
- `PUT /weather-api/weather/`: Update weather data for a specific city.
- `DELETE /weather-api/weather/`: Delete weather data for a specific city.Replace `` with the name of the city you want to perform the operation on.
## API Documentation
### Retrieve Weather Data
- **Endpoint**: `GET /weather-api/weather/`
- **Description**: Retrieve weather data for a specific city.
- **Response**: JSON object containing the weather information for the city.### Add Weather Data
- **Endpoint**: `POST /weather-api/weather`
- **Description**: Add new weather data for a city.
- **Request Body**: JSON object containing the city, temperature, and weather information.
- **Response**: JSON object containing the success message and the added weather data.### Update Weather Data
- **Endpoint**: `PUT /weather-api/weather/`
- **Description**: Update weather data for a specific city.
- **Request Body**: JSON object containing the updated temperature and/or weather information.
- **Response**: JSON object containing the updated weather data.### Delete Weather Data
- **Endpoint**: `DELETE /weather-api/weather/`
- **Description**: Delete weather data for a specific city.
- **Response**: JSON object confirming the deletion of the weather data.## Testing
The project includes test cases to verify the functionality of the API endpoints. The test cases are defined in the `tests/weather_test.py` file.
To run the tests, use the following command:
```shell
pytest tests/weather_test.py
```Note : Make sure you have the `pytest` library installed.