What I'm making:
An RSS reader with a couple (10 to 15) fixed feeds.
The problem:
When I hit refresh on the browser, it takes around 15 seconds to load.
I know that most of the loading time is waiting for the server to iterate over every feed and load all the entries from each one.
Maybe AJAX could be the solution?
Code:
This is the view:
@app.route('/')
def index():
RSS_URLS = [
'http://feeds.feedburner.com/RockPaperShotgun',
'http://www.gameinformer.com/b/MainFeed.aspx?Tags=preview',
'http://www.polygon.com/rss/group/news/index.xml',
]
entries = []
for url in RSS_URLS:
entries.extend(feedparser.parse(url).entries)
entries_sorted = sorted(
entries,
key=lambda e: e.published_parsed,
reverse=True)
return render_template(
'index.html',
entries=entries_sorted
)
And this is the template:
{% block content %}
<div class="row">
{% for e in entries %}
<div class="col-md-4 col-lg-3">
<h1><a href="{{ e.link }}">{{ e.title }}</a></h1>
<h5>Published on: {{ e.published }}</h5>
{% for content in e.content %}
<p>{{ content.value|safe }}</p>
{% else %}
<p>{{ e.summary_detail.value|safe }}</p>
{% endfor %}
</div>
{% endfor %}
</div>
{% endblock %}