This repository has been archived on 2023-10-10. You can view files and clone it, but cannot push or open issues/pull-requests.
www-main/main.py

31 lines
889 B
Python
Raw Normal View History

2013-01-27 03:23:25 +00:00
import feedparser
from flask import Flask, render_template
from time import mktime
from datetime import datetime
app = Flask('main')
app.config.from_pyfile('main.cfg')
def pull_feed_entries():
all_entries = []
for tag, url in app.config['FEEDS']:
entries = feedparser.parse(url).entries
for e in entries:
e.tag = tag
dt = datetime.fromtimestamp(mktime(e.updated_parsed))
e.updated_display = dt.strftime(app.config['DATE_FORMAT'])
all_entries.extend(entries)
all_entries.sort(key=lambda e: e.updated_parsed, reverse=True)
return all_entries[:app.config['MAX_ENTRIES']]
@app.route('/')
def main():
return render_template('main.html', entries=pull_feed_entries())
@app.route('/about')
def about():
return render_template('about.html')
if __name__ == '__main__':
app.run('0.0.0.0', 8080, debug=True)