<commit_before>import urllib.request
import json

BASE_URL = 'http://192.168.33.10/' # URL for backend here

md_news = []


def get_news():

    if len(md_news) == 0:
        url = BASE_URL + 'articles.php'
        news = json.loads(urllib.request.urlopen(url).read().decode("UTF-8"))

        for article in news:
            headline = '## {headline}  \n'.format(headline=article['headline'])
            img = '![Image]({})'.format(article['image']) if article['image'] != '' else None
            content = article['content']
            formated_article = '{headline}{img}{content}'.format(headline=headline if img is None else '',
                                                                 img=img if img is not None else '',
                                                                 content=content if img is None else '')
            md_news.append(formated_article)

    return md_news.pop()
<commit_msg>add try block for news<commit_after>import urllib.request
import json

BASE_URL = 'http://192.168.33.10/'  # URL for backend here

md_news = []


def get_news():

    if len(md_news) == 0:

        url = BASE_URL + 'articles.php'
        try:
            news = json.loads(urllib.request.urlopen(
                url).read().decode("UTF-8"))
        except:
            news = []
            md_news.append('## No News')

        if len(news) > 0:
            for article in news:
                headline = '## {headline}  \n'.format(headline=article['headline'])
                img = '![Image]({})'.format(article['image']) if article[
                    'image'] != '' else None
                content = article['content']
                formated_article = '{headline}{img}{content}'.format(headline=headline if img is None else '',
                                                                     img=img if img is not None else '',
                                                                     content=content if img is None else '')
                md_news.append(formated_article)

    return md_news.pop()

{'fraction_non_alphanumeric': 0.12846715328467154, 'fraction_numerical': 0.012165450121654502, 'mean_word_length': 1.5829145728643217, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3677443', 'n_tokens_mistral': 569, 'n_tokens_neox': 535, 'n_words': 133}