-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3ff5674
Showing
40 changed files
with
502 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
"""Django's command-line utility for administrative tasks.""" | ||
import os | ||
import sys | ||
|
||
|
||
def main(): | ||
"""Run administrative tasks.""" | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'weatherproject.settings') | ||
try: | ||
from django.core.management import execute_from_command_line | ||
except ImportError as exc: | ||
raise ImportError( | ||
"Couldn't import Django. Are you sure it's installed and " | ||
"available on your PYTHONPATH environment variable? Did you " | ||
"forget to activate a virtual environment?" | ||
) from exc | ||
execute_from_command_line(sys.argv) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
|
||
:root { | ||
--white: #ffffff; | ||
--off-white: #e5e5e5; | ||
--transp-white-1: rgba(255, 255, 255, 0.25); | ||
--transp-white-2: rgba(255, 255, 255, 0.18); | ||
--blue-1: #62b8f5; | ||
--blue-2: #4475ef; | ||
--shadow: rgba(3, 46, 87, 0.2); | ||
} | ||
/* body{ | ||
background: linear-gradient(270deg, var(--blue-1), var(--blue-2)); | ||
} */ | ||
*{ | ||
margin:0; | ||
padding:0; | ||
box-sizing:border-box; | ||
font-family: "Poppins", sans-serif; | ||
} | ||
h1{ | ||
text-align: center; | ||
color: rgb(5,41,51); | ||
margin-bottom: 15px; | ||
} | ||
h2{ | ||
font-size: 2rem; | ||
} | ||
form{ | ||
display:grid; | ||
grid-template-columns:72% 25%; | ||
grid-gap:3%; | ||
} | ||
.container{ | ||
width: 50%;; | ||
/* background-color: #77ACF1; */ | ||
background: var(--transp-white-2); | ||
backdrop-filter: blur(10px); | ||
margin: 5rem auto; | ||
padding: 2rem; | ||
border: 2px solid var(--transp-white-2); | ||
border-radius: 10px; | ||
color:rgb(5,41,51); | ||
height: 600px; | ||
} | ||
input, .btn ::placeholder{ | ||
background-color: transparent; | ||
|
||
/* color: var(--off-white); | ||
border-bottom: 2px solid var(--transp-white-1); */ | ||
padding: .5rem; | ||
border-radius: 10px; | ||
outline: none; | ||
border: 1px solid white; | ||
} | ||
.btn{ | ||
padding: .5rem 1rem; | ||
/* background-color:#F0EBCC ; | ||
color:#04009A ; */ | ||
border:2px solid #04009A ; | ||
cursor:pointer; | ||
transition:.3s; | ||
color: var(--blue-2); | ||
background-color: transparent; | ||
border-radius: 0.3em; | ||
} | ||
.btn:hover{ | ||
transform: translateY(-3px); | ||
background-color:rgb(5,41,51); | ||
color:#fff ; | ||
} | ||
.weather{ | ||
margin-top:3rem; | ||
display:flex; | ||
justify-content: space-between; | ||
align-items:center; | ||
height:200px; | ||
|
||
} | ||
.left{ | ||
width:100%; | ||
/* background-color:#343A40 ; */ | ||
padding:.3rem; | ||
padding-bottom: 0; | ||
border-radius:10px 0 0 10px; | ||
height:220px; | ||
line-height:3; | ||
text-transform: uppercase; | ||
background: var(--transp-white-2); | ||
backdrop-filter: blur(10px); | ||
|
||
} | ||
.temp{ | ||
text-align: center; | ||
margin-top: 15px; | ||
} | ||
.city{ | ||
margin-top: -22px; | ||
text-align: center; | ||
} | ||
.right{ | ||
border-radius:10px ; | ||
text-align:center; | ||
height:220px; | ||
width:100%; | ||
border-radius:0 10px 10px 0; | ||
/* margin-left:.5rem; */ | ||
line-height:2.5; | ||
background: var(--transp-white-2); | ||
backdrop-filter: blur(10px); | ||
|
||
} | ||
.icon{ | ||
|
||
/* background:#d8c6c6; */ | ||
height:85px; | ||
padding: .5rem; | ||
border-radius:0 10px 0 0; | ||
color:#04009A; | ||
/* filter: drop-shadow(0 1.8em 3.7em var(--shadow)); */ | ||
} | ||
.condition{ | ||
height:135px; | ||
/* background:#292929 ; */ | ||
/* padding: .5rem; */ | ||
border-radius:0 0 10px; | ||
color:rgb(5,41,51); | ||
font-size: 20px; | ||
} | ||
@media only screen and (max-width: 1000px) { | ||
.container{ | ||
width:80%; | ||
} | ||
} | ||
@media only screen and (max-width: 700px) { | ||
.weather { | ||
flex-direction:column; | ||
height:auto; | ||
} | ||
.container{ | ||
text-align:center; | ||
width:90%; | ||
height:90%; | ||
} | ||
.right{ | ||
margin-top:.5rem; | ||
margin-left:0; | ||
} | ||
form{ | ||
grid-template-columns:100%; | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
/* | ||
@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro:200'); */ | ||
|
||
body { | ||
background-image: url('https://images.pexels.com/photos/3008509/pexels-photo-3008509.jpeg?auto=compress&cs=tinysrgb&w=1600'); | ||
background-size:cover; | ||
background-repeat: no-repeat; | ||
margin: 0; | ||
width: 1920px; | ||
|
||
} | ||
|
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class WeatherappConfig(AppConfig): | ||
name = 'weatherapp' |
Empty file.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{% load static %} | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>My Weather App</title> | ||
<link rel="stylesheet" href="{% static 'style.css' %}"> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;500;600&display=swap" | ||
rel="stylesheet" | ||
/> | ||
</head> | ||
|
||
<body {% if exception_occurred %} | ||
style="background-image: url('https://images.pexels.com/photos/3008509/pexels-photo-3008509.jpeg?auto=compress&cs=tinysrgb&w=1600');" | ||
{% else %} | ||
style="background-image: url('{{ image_url }}');" | ||
{% endif %}> | ||
<div class="container"> | ||
<h1 class="heading">Weather App</h1> | ||
|
||
<form method="POST"> | ||
{% csrf_token %} | ||
<input type="text" name="city" placeholder="Enter City"> | ||
<button type="submit" class="btn">Search</button> | ||
</form> | ||
<div class="weather"> | ||
<div class="left"> | ||
<h2 class="temp">{{ temp }}° C</h2> | ||
<h2 class="city">{{ city }}</h2> | ||
</div> | ||
<div class="right"> | ||
<div class="icon"> | ||
<p><img src="http://openweathermap.org/img/w/{{ icon }}.png" width="120px"></p> | ||
</div> | ||
<div class="condition"> | ||
<p>{{ description }}</p> | ||
<p>{{ day }}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
{% if exception_occurred %} | ||
<script> | ||
window.onload = function() { | ||
alert("City information is not available to Weather API"); | ||
} | ||
</script> | ||
{% endif %} | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.urls import path | ||
from . import views | ||
urlpatterns = [ | ||
path('', views.home), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from django.shortcuts import render | ||
from django.contrib import messages | ||
import requests | ||
import datetime | ||
|
||
|
||
def home(request): | ||
|
||
if 'city' in request.POST: | ||
city = request.POST['city'] | ||
else: | ||
city = 'indore' | ||
|
||
url = f'https://api.openweathermap.org/data/2.5/weather?q={city}&appid=ad4bbb96fa3d51295147d143d029e1ba' | ||
PARAMS = {'units':'metric'} | ||
|
||
API_KEY = 'AIzaSyA_w0pPujrG3Eii303pqnCeBhIzYBcdvlU' | ||
SEARCH_ENGINE_ID = '078378d643c1e45f7' | ||
|
||
|
||
|
||
query = city + " 1920x1080" | ||
page = 1 | ||
start = (page - 1) * 10 + 1 | ||
searchType = 'image' | ||
city_url = f"https://www.googleapis.com/customsearch/v1?key={API_KEY}&cx={SEARCH_ENGINE_ID}&q={query}&start={start}&searchType={searchType}&imgSize=xlarge" | ||
|
||
data = requests.get(city_url).json() | ||
count = 1 | ||
search_items = data.get("items") | ||
image_url = search_items[1]['link'] | ||
|
||
|
||
try: | ||
|
||
data = requests.get(url,params=PARAMS).json() | ||
description = data['weather'][0]['description'] | ||
icon = data['weather'][0]['icon'] | ||
temp = data['main']['temp'] | ||
day = datetime.date.today() | ||
|
||
return render(request,'weatherapp/index.html' , {'description':description , 'icon':icon ,'temp':temp , 'day':day , 'city':city , 'exception_occurred':False ,'image_url':image_url}) | ||
|
||
except KeyError: | ||
exception_occurred = True | ||
messages.error(request,'Entered data is not available to API') | ||
# city = 'indore' | ||
# data = requests.get(url,params=PARAMS).json() | ||
|
||
# description = data['weather'][0]['description'] | ||
# icon = data['weather'][0]['icon'] | ||
# temp = data['main']['temp'] | ||
day = datetime.date.today() | ||
|
||
return render(request,'weatherapp/index.html' ,{'description':'clear sky', 'icon':'01d' ,'temp':25 , 'day':day , 'city':'indore' , 'exception_occurred':exception_occurred } ) | ||
|
||
|
||
|
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
ASGI config for weatherproject project. | ||
It exposes the ASGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'weatherproject.settings') | ||
|
||
application = get_asgi_application() |
Oops, something went wrong.