Skip to content

sowousmane/flask-weather

Repository files navigation

SoWeather Flask Application

SoWeather is a simple Flask web application Application that provides weather information for a specified location. It is built using Python and Flask framework.

The SoWeather Flask Application was created following the tutorial https://dev.to/cscarpitta/creating-a-simple-weather-app-with-python-and-flask-5bpd/ written by initialy https://dev.to/cscarpitta

Features

  • Retrieve current weather data for a specified location.
  • Display the temperature, humidity, and weather description.

Prerequisites

Before running the application, ensure that the following dependencies are installed:

  • Python 3.x
  • Flask
  • requests
  • having a OpenWeather account for token/API-KEY

You can install the required packages by running the following command:

pip install -r requirements.txt

Getting Started

To set up and run the Weather Flask Application on your local machine, follow these steps:

  1. Clone the project repository to your computer
git clone https://github.com/sowousmane/Flask.git
  1. Change to the project directory
cd Flask
  1. Create a virtual environment
python3 -m venv venv
  1. Activate the virtual environment
  • On macOS and Linux:
source env/bin/activate
  • On Windows:
env\Scripts\activate
  1. Install the required dependencies:
pip install -r requirements.txt
  1. Create a .env file
OPEN_WEATHER_TOKEN=your_weather_token
  1. Run the application:
flask --app weather.py --debug run
  1. Open your web browser and navigate to http://localhost:5000 to access the Weather Flask Application.

Running with Docker Compose

To run the Weather Flask Application using Docker Compose, follow these steps:

  1. Make sure you have Docker and Docker Compose installed on your machine. You can download and install them from the official Docker website.

  2. Clone the project repository to your computer

git clone https://github.com/sowousmane/Flask.git
  1. Change to the project directory
cd Flask
  1. Create a .env file
OPEN_WEATHER_TOKEN=your_weather_token
  1. Build and start the Docker containers using Docker Compose:
docker-compose up -d

This command will build the Docker image and start the containers in detached mode.

  1. Open your web browser and navigate to http://localhost:5000 to access the Weather Flask Application running with Docker Compose.

  2. To stop and remove the containers, run the following command in the project directory:

docker-compose down

This will stop and remove the containers created by Docker Compose.

Running in Docker

To run the Weather Flask Application in Docker, follow these steps:

  1. Make sure you have Docker installed on your machine. You can download and install Docker from the official Docker website.

  2. Puul and run the image in your computer:

docker run --rm -e OPEN_WEATHER_TOKEN=your_token -p 5005:5000 kbosow/flask-weather:0.1.0

Credits

The Weather Flask Application was developed following the tutorial "Creating a Simple Weather App with Python and Flask" by Carlo Scarpitta.

License

This project is licensed under the MIT License.