<commit_before># coding=utf-8
from flask import Flask
from requests import get

import json

from settings import *


app = Flask(__name__)


@app.route('/api/<city>', methods=['GET'])
def get_weather(city):
    response = get(WEATHER_DATA.format(city))
    json_data = response.json()

    try:
        return_data = json_data['list'][-1]['temp']['eve']
    except:
        return_data = ["Error parsing weather data"]


    return json.dumps(return_data)


if __name__ == '__main__':
    app.debug = True
    app.run(IP_HOST, PORT_HOST)<commit_msg>added check connnection to openweathermap<commit_after># coding=utf-8
from flask import Flask
from requests import get

import json

from settings import *


app = Flask(__name__)


@app.route('/api/<city>', methods=['GET'])
def get_weather(city):
    response = get(WEATHER_DATA.format(city))

    if response.status_code == 200:
        json_data = response.json()
        
        try:
            last_day =  max(json_data['list'], key=lambda x: x['dt'])
            return_data = last_day['temp']['eve']
        except:
            return_data = {'error': "Error parsing weather data"}
    else:
        return_data = {'error': "Error obtaining data form openweathermap"}

    return json.dumps(return_data)


if __name__ == '__main__':
    app.debug = True
    app.run(IP_HOST, PORT_HOST)
{'fraction_non_alphanumeric': 0.13020833333333334, 'fraction_numerical': 0.004464285714285714, 'mean_word_length': 3.3108974358974357, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1293201', 'n_tokens_mistral': 448, 'n_tokens_neox': 424, 'n_words': 106}