A beautiful, modern weather application that provides real-time weather data, 5-day forecasts, and dynamic backgrounds that change based on weather conditions. Built with Flask and vanilla CSS featuring stunning glassmorphism design.
The Weather App is a full-stack web application that delivers accurate weather information for any city worldwide. With its intuitive interface, animated weather effects, and responsive design, users can easily check current conditions and upcoming forecasts. The app features automatic location detection, search history, and theme customization.
- Search by City Name - Find weather for any city worldwide
- Auto Location Detection - Use browser geolocation to get local weather instantly
- Recent Searches - Quick access to last 5 searched cities
- Intelligent Error Handling - Clear messages for invalid cities or API issues
- Current Temperature - Large, easy-to-read temperature display
- Celsius/Fahrenheit Toggle - Switch between temperature units instantly
- Feels Like Temperature - Real feel temperature display
- Weather Conditions - Clear descriptions (Sunny, Cloudy, Rainy, etc.)
- Animated Weather Icons - Beautiful emoji-based weather icons
- Detailed Metrics - Humidity, wind speed, sunrise, and sunset times
- Daily Forecasts - See weather predictions for the next 5 days
- High/Low Temperatures - Daily temperature ranges
- Weather Icons - Visual representation of each day's conditions
- Horizontal Scroll Cards - Beautiful card-based forecast display
- Dynamic Backgrounds - Background changes based on weather conditions:
- βοΈ Clear/Sunny β Warm orange/yellow gradient
- βοΈ Cloudy β Cool gray/blue gradient
- π§οΈ Rainy β Deep blue gradient with rain animation
- βοΈ Snowy β White/light blue gradient with snow animation
- π Night β Dark navy/purple gradient
- βοΈ Thunderstorm β Dark gray with dramatic effect
- Glassmorphism Design - Modern frosted glass effect cards
- Smooth Animations - Fade-in effects, floating icons, and hover animations
- Weather Animations - Rain drops falling, snow flakes, and cloud movements
- Dark/Light Mode Toggle - Manual theme switch button
- Auto System Detection - Automatically matches your system theme
- Persistent Preference - Remembers your theme choice
- Mobile Friendly - Fully responsive on all devices
- Tablet Optimized - Perfect layout for medium screens
- Desktop Enhanced - Beautiful full-screen experience
- Framework: Flask (Python 3.8+)
- HTTP Client: Requests library
- API: OpenWeatherMap API (free tier)
- HTML5 - Semantic markup
- Vanilla CSS3 - No frameworks, pure custom styling
- Glassmorphism effects
- CSS Grid & Flexbox
- Custom animations
- Media queries for responsiveness
- Vanilla JavaScript - No libraries
- Fetch API for HTTP requests
- LocalStorage for data persistence
- Geolocation API
- System theme detection
- OpenWeatherMap API
- Current Weather Data API
- 5 Day / 3 Hour Forecast API
- Free tier (1000 calls/day)
weather-app/
βββ app.py # Main Flask application
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ .gitignore # Git ignore rules
βββ static/
β βββ style.css # All CSS styles and animations
β βββ script.js # All JavaScript functionality
βββ templates/
βββ index.html # Main HTML page
- Python 3.8 or higher
- pip (Python package manager)
- Internet connection
- OpenWeatherMap API key (free)
git clone <your-repository-url>
cd weather-app-
Go to OpenWeatherMap
-
Create Account
- Click "Sign Up" and create a free account
- Verify your email address
-
Get API Key
- Log in to your account
- Go to "API keys" section in your profile
- Copy your default API key (or create a new one)
- Note: New API keys may take 10-15 minutes to activate
-
Add API Key to App
- Open
app.pyin a text editor - Find the line:
API_KEY = "YOUR_API_KEY_HERE" - Replace
YOUR_API_KEY_HEREwith your actual API key - Save the file
- Open
pip install -r requirements.txtThis will install:
- Flask - Web framework
- Requests - HTTP library for API calls
- Werkzeug - WSGI utility library
python app.pyYou should see:
π€οΈ Weather App Starting...
π Access the app at: http://localhost:5000
β
API key configured
- Navigate to:
http://localhost:5000 - The app will load with New Delhi weather by default
- Start searching for your city!
-
By City Name:
- Type city name in the search box
- Press Enter or click Search button
- Examples: "London", "Tokyo", "New York"
-
By Location:
- Click the π location button
- Allow location access when prompted
- Weather for your current location will display
-
Using Recent Searches:
- Click any city chip below the search bar
- Instantly loads that city's weather
- Click Β°C button for Celsius (default)
- Click Β°F button for Fahrenheit
- All temperatures update instantly
- Click the βοΈ/π button in the header
- Toggle between light and dark modes
- Your preference is saved automatically
The app dynamically changes its background based on current weather:
| Weather Condition | Background | Animation |
|---|---|---|
| βοΈ Clear/Sunny (Day) | Warm orange/yellow gradient | Floating sun icon |
| π Clear (Night) | Dark navy/purple gradient | Floating moon icon |
| βοΈ Cloudy | Cool gray/blue gradient | Moving clouds |
| π§οΈ Rainy | Deep blue gradient | Falling rain drops |
| π¦οΈ Drizzle | Light blue gradient | Light rain effect |
| βοΈ Thunderstorm | Dark gray | Lightning effect |
| βοΈ Snowy | White/light blue gradient | Falling snowflakes |
| π«οΈ Mist/Fog | Gray gradient | Foggy overlay |
Problem: You see this error when searching for weather
Solution:
- Make sure you've added your API key to
app.py - Replace
YOUR_API_KEY_HEREwith your actual key - Restart the Flask server
Problem: Search returns city not found
Solution:
- Check spelling of city name
- Try with country name: "Paris, FR"
- Use major city names (avoid small towns)
Problem: Valid API key but still getting errors
Solution:
- New API keys take 10-15 minutes to activate
- Wait and try again
- Check if you've exceeded free tier limit (1000 calls/day)
Problem: Location button doesn't work
Solution:
- Make sure you're using HTTPS or localhost
- Allow location permissions in browser
- Check browser console for errors
Problem: Server starts but page doesn't load
Solution:
# Check if port 5000 is already in use
python app.py
# Try a different port
# Edit app.py and change port in last line
app.run(debug=True, host='0.0.0.0', port=5001)GET /api/weather/city/<city_name>
Response Example:
{
"city": "New Delhi",
"country": "IN",
"temperature": 25,
"feels_like": 27,
"humidity": 60,
"wind_speed": 15.5,
"description": "Clear Sky",
"main": "Clear",
"icon": "01d",
"sunrise": "06:30",
"sunset": "18:45",
"forecast": [...]
}GET /api/weather/coordinates?lat=<latitude>&lon=<longitude>
- No User Data Stored: The app doesn't store any personal information
- Local Storage Only: Recent searches stored locally in browser
- Location Privacy: Location data only used for weather API call
- No Tracking: No analytics or tracking scripts
- Hourly forecast display
- Weather alerts and warnings
- Air quality index
- UV index display
- Weather radar map
- Multiple location favorites
- Weather widgets
- PWA support for mobile installation
- Share weather on social media
Vikrant Rana
- π BCA Aspirant
- π Location: Delhi, India
- πΌ Role: Full Stack Developer
- π― Passion: Building beautiful and functional web applications
This project was developed to showcase full-stack development skills, API integration, responsive design, and modern UI/UX practices using vanilla technologies.
This project is open source and available for educational purposes.
- OpenWeatherMap - For providing free weather API
- Google Fonts - Inter and Poppins font families
- Flask Community - For the excellent web framework
- Python Community - For amazing tools and libraries
If you encounter any issues:
- Check the troubleshooting section above
- Verify your API key is correctly configured
- Check browser console for JavaScript errors
- Ensure you have a stable internet connection
Modern frosted glass effect with backdrop blur and transparency
- Fade-in effects when loading data
- Floating weather icons
- Hover effects on cards
- Rain and snow animations
- Auto-detects system preference
- Manual override option
- Smooth theme transitions
- Persistent across sessions
- Mobile-first approach
- Touch-friendly buttons
- Optimized for all screen sizes
- Works on any device
Built with β€οΈ by Vikrant Rana | Β© 2024 Weather App
Get accurate weather forecasts anytime, anywhere! π€οΈ