├── requirements.txt ├── app.cpython-311.pyc ├── weather.cpython-311.pyc ├── app.py ├── README.md ├── weather.py └── index.html /requirements.txt: -------------------------------------------------------------------------------- 1 | colorama==0.4.6 2 | Flask==3.0.2 -------------------------------------------------------------------------------- /app.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sabarnashinchu/weather_show/HEAD/app.cpython-311.pyc -------------------------------------------------------------------------------- /weather.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sabarnashinchu/weather_show/HEAD/weather.cpython-311.pyc -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request, jsonify 2 | from weather import generate_weather_data 3 | 4 | app = Flask(__name__) 5 | 6 | @app.route('/') 7 | def home(): 8 | return render_template('index.html') 9 | 10 | @app.route('/get_weather', methods=['POST']) 11 | def get_weather(): 12 | city = request.form.get('city') 13 | if not city: 14 | return jsonify({'error': 'Please enter a city name'}), 400 15 | 16 | weather_data = generate_weather_data(city) 17 | return jsonify(weather_data) 18 | 19 | if __name__ == '__main__': 20 | app.run(debug=True) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Weather Show (Simulation Mode) 2 | 3 | A simple command-line weather simulation application that displays generated weather information for any city. This version works without requiring any API keys! 4 | 5 | ## Features 6 | 7 | - Simulated weather data with realistic patterns 8 | - Colored output for better readability 9 | - Displays temperature, feels like temperature, conditions, humidity, wind speed, sunrise, and sunset times 10 | - Metric units (Celsius, meters per second) 11 | - Four weather patterns: Sunny, Cloudy, Rainy, and Stormy 12 | 13 | ## Setup 14 | 15 | 1. Install the required dependency: 16 | ``` 17 | pip install -r requirements.txt 18 | ``` 19 | 20 | ## Usage 21 | 22 | 1. Run the program: 23 | ``` 24 | python weather.py 25 | ``` 26 | 2. Enter any city name to get simulated weather information 27 | 3. Type 'quit' to exit the program 28 | 29 | ## Requirements 30 | 31 | - Python 3.6 or higher 32 | - No internet connection required! -------------------------------------------------------------------------------- /weather.py: -------------------------------------------------------------------------------- 1 | from colorama import Fore, Style, init 2 | from datetime import datetime 3 | import random 4 | 5 | # Initialize colorama 6 | init() 7 | 8 | # Predefined weather patterns 9 | WEATHER_PATTERNS = { 10 | 'Sunny': { 11 | 'temp_range': (20, 30), 12 | 'humidity_range': (30, 50), 13 | 'wind_range': (0, 10), 14 | 'description': 'Clear sunny skies' 15 | }, 16 | 'Cloudy': { 17 | 'temp_range': (15, 25), 18 | 'humidity_range': (50, 70), 19 | 'wind_range': (5, 15), 20 | 'description': 'Partly cloudy' 21 | }, 22 | 'Rainy': { 23 | 'temp_range': (10, 20), 24 | 'humidity_range': (70, 90), 25 | 'wind_range': (10, 20), 26 | 'description': 'Light rain' 27 | }, 28 | 'Stormy': { 29 | 'temp_range': (8, 15), 30 | 'humidity_range': (80, 95), 31 | 'wind_range': (20, 30), 32 | 'description': 'Thunder storms' 33 | } 34 | } 35 | 36 | def generate_weather_data(city): 37 | # Randomly select a weather pattern 38 | weather_type = random.choice(list(WEATHER_PATTERNS.keys())) 39 | pattern = WEATHER_PATTERNS[weather_type] 40 | 41 | # Generate random values within the pattern's ranges 42 | temp = round(random.uniform(*pattern['temp_range']), 1) 43 | feels_like = round(temp + random.uniform(-2, 2), 1) 44 | humidity = round(random.uniform(*pattern['humidity_range'])) 45 | wind_speed = round(random.uniform(*pattern['wind_range']), 1) 46 | 47 | # Generate sunrise and sunset times 48 | base_sunrise = datetime.now().replace(hour=6, minute=0) 49 | base_sunset = datetime.now().replace(hour=18, minute=0) 50 | sunrise_offset = random.randint(-30, 30) 51 | sunset_offset = random.randint(-30, 30) 52 | 53 | return { 54 | 'city': city, 55 | 'temp': temp, 56 | 'feels_like': feels_like, 57 | 'humidity': humidity, 58 | 'wind_speed': wind_speed, 59 | 'description': pattern['description'], 60 | 'sunrise': (base_sunrise.hour * 60 + base_sunrise.minute + sunrise_offset) // 60, 61 | 'sunrise_mins': (base_sunrise.hour * 60 + base_sunrise.minute + sunrise_offset) % 60, 62 | 'sunset': (base_sunset.hour * 60 + base_sunset.minute + sunset_offset) // 60, 63 | 'sunset_mins': (base_sunset.hour * 60 + base_sunset.minute + sunset_offset) % 60 64 | } 65 | 66 | def display_weather(weather_data): 67 | print(f"\n{Fore.CYAN}Weather in {weather_data['city']}{Style.RESET_ALL}") 68 | print("=" * 40) 69 | print(f"{Fore.YELLOW}Temperature: {Fore.WHITE}{weather_data['temp']}°C") 70 | print(f"{Fore.YELLOW}Feels like: {Fore.WHITE}{weather_data['feels_like']}°C") 71 | print(f"{Fore.YELLOW}Conditions: {Fore.WHITE}{weather_data['description']}") 72 | print(f"{Fore.YELLOW}Humidity: {Fore.WHITE}{weather_data['humidity']}%") 73 | print(f"{Fore.YELLOW}Wind Speed: {Fore.WHITE}{weather_data['wind_speed']} m/s") 74 | print(f"{Fore.YELLOW}Sunrise: {Fore.WHITE}{weather_data['sunrise']:02d}:{weather_data['sunrise_mins']:02d}") 75 | print(f"{Fore.YELLOW}Sunset: {Fore.WHITE}{weather_data['sunset']:02d}:{weather_data['sunset_mins']:02d}") 76 | print("=" * 40) 77 | 78 | def main(): 79 | print(f"{Fore.CYAN}Welcome to Weather Show! (Simulation Mode){Style.RESET_ALL}") 80 | print(f"{Fore.GREEN}This is a demo version that generates simulated weather data.{Style.RESET_ALL}") 81 | 82 | while True: 83 | city = input(f"\n{Fore.GREEN}Enter city name (or 'quit' to exit): {Style.RESET_ALL}") 84 | if city.lower() == 'quit': 85 | print(f"\n{Fore.CYAN}Thank you for using Weather Show! Goodbye!{Style.RESET_ALL}") 86 | break 87 | 88 | weather_data = generate_weather_data(city) 89 | display_weather(weather_data) 90 | 91 | if __name__ == "__main__": 92 | main() -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Weather Show 7 | 8 | 122 | 123 | 124 |
125 |

Weather Show

126 | 130 |
131 |
132 |
133 |
134 | Temperature 135 | 136 |
137 |
138 | Feels Like 139 | 140 |
141 |
142 | Conditions 143 | 144 |
145 |
146 | Humidity 147 | 148 |
149 |
150 | Wind Speed 151 | 152 |
153 |
154 | Sunrise 155 | 156 |
157 |
158 | Sunset 159 | 160 |
161 |
162 |
163 | 164 | 225 | 226 | --------------------------------------------------------------------------------