Beispiel #1
0
def index():
    url = 'http://api.openweathermap.org/data/2.5/weather?id=%s&appid=%s&units=metric' % (
        city_id, weather_apikey)
    weather = get_weather(url)
    result = '<p>Temperature: %s </p>' % weather['main']['temp']
    result += '<p>City: %s</p>' % weather['name']
    return result
Beispiel #2
0
def index():
	url = "http://api.openweathermap.org/data/2.5/weather?id=%s&APPID=%s&units=metric" % (city_id, settings.API_KEY)
	weather = get_weather(url)
	cur_date = datetime.now().strftime(' %A  %d %B')
	result = "<p> Tемпература за бортом: %s </p>" % weather ['main']['temp']
	result += "<p>  <b> Mы летим над городом: </b> %s </p>" % weather['name']
	result += "<p> Today is : %s </p>" % cur_date
	return result
Beispiel #3
0
def index():
    url = "text" % (city_id, apikey)
    weather = get_weather(url)
    cur_date = datetime.now().strftime('%D.%m.%Y')

    result = "<p><b>Temperature:</b> %s</p>" % weather['main']['temp']
    result += "<p><b>City:</b> %s</p>" % weather['name']
    result += "<p><b>Date:</b> %s</p>" % cur_date
    return result
Beispiel #4
0
def index():
    url = "http://api.openweathermap.org/data/2.5/weather?id=%s&APPID=%s&units=metric" % (
        city_id, apikey)
    weather = get_weather(url)
    date_now = datetime.now().strftime('%d.%m.%Y')
    result = "<p><b>Температура: <b>%s<p>" % weather['main']['temp']
    result += "<p><b>Город: <b>%s<p>" % weather['name']
    result += "<p><b>Дата: <b>%s<p>" % date_now
    return result
Beispiel #5
0
def index():
	url = "http://api.openweathermap.org/data/2.5/weather?id=%s&APPID=%s&units=metric" % (city_id, apikey)
	weather = get_weather(url)
	cur_data = datetime.now().strftime('%d-%m-%Y')
	
	result = '<p><b>Температура:</b> %s </p>' % weather['main']['temp']
	result += '<p><b>Город:</b> %s </p>' % weather['name']
	result += '<p><b>Дата:</b> %s </p>' % cur_data
	return result
Beispiel #6
0
def index():
    url = 'https://api.openweathermap.org/data/2.5/weather?q={}&APPID={}&units={}'.format(
        city, apikey, units)
    weather = get_weather(url)
    cur_date = datetime.now().strftime('%d.%m.%Y')
    result = '<p><b>Температура:</b> {}</p>'.format(weather['main']['temp'])
    result += '<p><b>Город:</b> {}</p>'.format(weather['name'])
    result += '<p><b>Дата:</b> {}</[>'.format(cur_date)
    return result
Beispiel #7
0
def index():
    url = "http://api.openweathermap.org/data/2.5/weather?id=%s&APPID=%s&units=metric" % (
        city_id, apikey)
    weather = get_weather(url)
    print('type ', type(weather))
    cur_date = datetime.now().strftime('%d,%m,%Y')

    result = "<p><b>T:<b> %s<p>" % weather['main']['temp']
    result += '<p><b>Город:<b> %s<p>' % weather['name']
    result += '<p><b>Date:<b>%s<p>' % cur_date
    return result
Beispiel #8
0
def index():
    url = 'http://api.openweathermap.org/data/2.5/weather?id={}&APPID={}&units=metric'.format(
        city_id, apikey)
    weather = get_weather(url)
    cur_date = datetime.now().strftime('%d %b %y')

    result = '<p><b>Температура</b>: {}\n</p>'.format(weather['main']['temp'])
    result += '<p>Город: {}\n</p>'.format(weather['name'])
    result += '<p>Ветер: {}м/с</p>'.format(weather['wind']['speed'])
    result += '<p><b>Дата:</b> {}</p>'.format(cur_date)
    return result
Beispiel #9
0
def index():
    url = 'http://api.openweathermap.org/data/2.5/weather?id=%s&appid=%s&units=metric' % (city_id, apikey)
    cur_date = datetime.now().strftime('%d,%m,%Y')
 
    weather = get_weather(url)

    result = '<p><b>температура : </b> %s </p>' % weather['main']['temp']
    result += '<p><b>температура min : </b> %s </p>' % weather['main']['temp_min']
    result += '<p><b>температура max: </b> %s </p>' % weather['main']['temp_max']
    result += '<p><b>Город : </b> %s </p>' % weather['name']
    result += '<p><b>Дата: </b> %s </p>' % cur_date
    return result
Beispiel #10
0
def weater_page():
    api_key = "871a34381b7f452a92d6f61c7e62c4df"
    city_id = 524901
    url = "http://api.openweathermap.org/data/2.5/weather?id={city}&APPID={key}&units=metric".format(
        city=city_id, key=api_key)
    weather = get_weather(url)
    page_data = """<p><b>Сегодня - </b> {data}</p>
    <p>в городе <b>{city}</b> <b>температура на улице</b> {temp} в градусах Цельсия</p>
    <a href="/">Вернуться на главную</a>
    """.format(data=datetime.now().strftime("%d.%m.%Y"),
               city=weather["name"],
               temp=weather['main']['temp'])

    return page_data
Beispiel #11
0
import requests

from req import get_weather

weather = get_weather('http://api.openweathermap.org/data/2.5/weather?id=524901%s&APPID=02c1c930bc0639e03991e42db1430484%s&units=metric')

print(weather)