Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ismail-mouyahada/master-api-weather-station
This project is a weather station application that uses a Flask backend to manage data related to temperature, humidity, and sensors, and a MySQL database to store the data. The API provides endpoints to add, read, update, and delete records in the database.
https://github.com/ismail-mouyahada/master-api-weather-station
flask flask-api python3
Last synced: 3 days ago
JSON representation
This project is a weather station application that uses a Flask backend to manage data related to temperature, humidity, and sensors, and a MySQL database to store the data. The API provides endpoints to add, read, update, and delete records in the database.
- Host: GitHub
- URL: https://github.com/ismail-mouyahada/master-api-weather-station
- Owner: Ismail-Mouyahada
- Created: 2022-05-09T19:51:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-30T18:55:46.000Z (7 months ago)
- Last Synced: 2024-05-30T21:55:19.584Z (7 months ago)
- Topics: flask, flask-api, python3
- Language: Python
- Homepage: https://www.ismail-mouyahada.com/
- Size: 783 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Weather Station API
This project is a weather station application that uses a Flask backend to manage data related to temperature, humidity, and sensors, and a MySQL database to store the data. The API provides endpoints to add, read, update, and delete records in the database.
## Features
- **Add Data**: Insert new records into the database.
- **Fetch Data**: Retrieve all records or specific records by ID.
- **Update Data**: Modify existing records.
- **Delete Data**: Remove records from the database.
- **Error Handling**: Return appropriate error messages for invalid requests.## Prerequisites
- Python 3.x
- Flask
- Flask-MySQL
- PyMySQL## Installation
1. Clone the repository:
```bash
git clone https://github.com/Ismail-Mouyahada/Master-csharp-vuejs-app.git
```2. Navigate to the project directory:
```bash
cd Master-csharp-vuejs-app
```3. Set up a virtual environment and activate it:
```bash
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
```4. Install the required packages:
```bash
pip install -r requirements.txt
```5. Configure the MySQL database connection in `config.py`:
```python
MYSQL_DATABASE_USER = 'your_mysql_username'
MYSQL_DATABASE_PASSWORD = 'your_mysql_password'
MYSQL_DATABASE_DB = 'your_database_name'
MYSQL_DATABASE_HOST = 'localhost'
```## Running the Application
1. Start the Flask application:
```bash
python app.py
```2. The API will be available at `http://192.168.43.60:5000`.
## API Endpoints
### Add Data
- **Endpoint**: `/api/v1/ajouter/`
- **Method**: `POST`
- **Description**: Add a new record to the `donnees` table.
- **Request Body**:
```json
{
"farenheit": "value",
"temperature": "value",
"humidite": "value",
"capture": "value"
}
```
- **Response**:
```json
{
"message": "les données ont été enregistrées avec succès !"
}
```### Fetch All Data
- **Endpoint**: `/api/v1/donnees/`
- **Method**: `GET`
- **Description**: Retrieve all records from the `donnees` table.
- **Response**: Array of records.### Fetch Data by ID (Humidity)
- **Endpoint**: `/api/v1/donnees/humidite/`
- **Method**: `GET`
- **Description**: Retrieve a specific record by ID from the `donnees` table.
- **Response**: Record details.### Fetch Data by ID (Temperature)
- **Endpoint**: `/api/v1/donnees/temperature/`
- **Method**: `GET`
- **Description**: Retrieve a specific record by ID from the `donnees` table.
- **Response**: Record details.### Update Data
- **Endpoint**: `/api/v1/modifier/`
- **Method**: `PUT`
- **Description**: Update an existing record in the `donnees` table.
- **Request Body**:
```json
{
"id": "value",
"farenheit": "value",
"temperature": "value",
"humidite": "value",
"date": "value",
"capture": "value"
}
```
- **Response**:
```json
{
"message": "les données ont été modifié avec succès"
}
```### Delete Data
- **Endpoint**: `/api/v1/supprimer/`
- **Method**: `DELETE`
- **Description**: Delete a record from the `donnees` table by ID.
- **Response**:
```json
{
"message": "Données ont été supprimées avec succès!"
}
```## Error Handling
- **404 Error**:
- **Description**: Returns a message when a requested resource is not found.
- **Response**:
```json
{
"status": 404,
"message": "Enregistrement introuvable mais l'api marche : "
}
```## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
## Contact
For any inquiries or feedback, please contact Ismail Mouyahada at [[email protected]](mailto:[email protected]).