Skip to content

yadasai161101/weather-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 Weather Python Application

A simple Python Flask application that fetches real-time weather information using the OpenWeather API. This project is built for learning Python, Docker containerization, and GitHub workflows.


🚀 Features

  • Real-time weather lookup
  • Flask + HTML template front-end
  • Dockerized application
  • API key support using environment variables
  • Ready for CI/CD using GitHub Actions

📁 Project Structure

weather-python/
│── app.py
│── requirements.txt
│── Dockerfile
│── templates/
│     └── index.html
│── README.md

🐍 1. Run Locally (Python)

Create and activate virtual environment

python -m venv venv
.\venv\Scripts\activate    # Windows

Install dependencies

pip install -r requirements.txt

Set API Key (OpenWeather)

$env:WEATHER_API_KEY="your_api_key_here"

Run the application

python app.py

App runs at:

👉 http://localhost:5000


🐳 2. Run with Docker

Build Docker image

docker build -t username/weather-app:latest .

Run container

docker run -p 5000:5000 -e WEATHER_API_KEY=your_api_key username/weather-app:latest

App available at:

👉 http://localhost:5000


📝 3. Git Commands (Push to GitHub)

Initialize Git

git init

Add and commit

git add .
git commit -m "Initial commit"

Rename branch to main

git branch -M main

Add remote origin

git remote add origin <your-repo-url>

Push to GitHub

git push -u origin main

If push is rejected due to history difference

git pull origin main --allow-unrelated-histories
git push origin main

🔑 Environment Variables

Variable Description
WEATHER_API_KEY Your OpenWeather map API key

🛠️ 4. Dockerfile (used for building image)

FROM python:3.10-slim
ARG WEATHER_API_KEY
ENV WEATHER_API_KEY=$WEATHER_API_KEY
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["python", "app.py"]

❤️ Contributing

Feel free to fork the repo and submit pull requests.


📧 Support

For any issues, open a GitHub issue in this repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors