diff options
author | André Glüpker <git@wgmd.de> | 2021-05-05 20:09:30 +0200 |
---|---|---|
committer | André Glüpker <git@wgmd.de> | 2021-05-05 20:09:30 +0200 |
commit | 5774dbfb2caa42cb55bafab98a40e47f395e44d9 (patch) | |
tree | 8294b7b6fefebc1befeed4104f3b5604683999a8 /webapp.py | |
download | rss-feeds-5774dbfb2caa42cb55bafab98a40e47f395e44d9.tar.gz rss-feeds-5774dbfb2caa42cb55bafab98a40e47f395e44d9.tar.bz2 rss-feeds-5774dbfb2caa42cb55bafab98a40e47f395e44d9.zip |
Initial commit of RSS converter application
Diffstat (limited to 'webapp.py')
-rwxr-xr-x | webapp.py | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/webapp.py b/webapp.py new file mode 100755 index 0000000..b992150 --- /dev/null +++ b/webapp.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python3 + +# from flask import Flask, redirect, render_template, request, session, url_for +from flask import Flask, Response + +# from wsgiref.util import setup_testing_defaults +from collections import OrderedDict +from concurrent.futures import ThreadPoolExecutor + +import json +import os +import re +import sys +import time, datetime +# import traceback +import logging + +from twitter import twitter +from telegram import telegram +from netto import netto +from rss import buildRSS +from zdf import zdf + +app = Flask(__name__) +app.secret_key = "NMcgoB.0wd+$.KVKj!F{3>U{%BBUVhL=7=5$:46rQH$Q{enCuU" + + +@app.route("/") +def main(): + return 'this is sparta' + +@app.errorhandler(404) +def not_found(e): + return 'Die angeforderte Seite konnte nicht gefunden werden.' + +@app.route("/twitter/<account>") +def feedTwitter(account): + content = [{'title': t, 'url': u, 'content': c, 'date': d, 'enclosures': e} + for t,c,u,d,e in twitter(account)] + xml = buildRSS( + title = 'Twitter: ' + account, + url = 'https://twitter.com/' + account, + description = 'The latest entries of the twitter account of ' + account, + content = content) + response = Response(xml, mimetype='text/xml') + response.headers['Access-Control-Allow-Origin'] = '*' + return response + +@app.route("/telegram/<account>") +def feedTelegram(account): + content = [{'title': t, 'url': u, 'content': c, 'date': d} + for t,c,u,d in telegram(account)] + xml = buildRSS( + title = 'Telegram: ' + account, + url = 'https://t.me/s/' + account, + description = 'The latest entries of the telegram channel of ' + account, + content = content) + response = Response(xml, mimetype='text/xml') + response.headers['Access-Control-Allow-Origin'] = '*' + return response + +@app.route("/netto/<market>") +def feedNetto(market): + title, url = netto(market) + content = [{ + 'title': 'Angebote für ' + title, + 'url': url, + 'content': 'Angebote für ' + title + ' finden sich unter ' + url, + }] + xml = buildRSS( + title = 'Netto Angebote für ' + market, + url = 'https://www.netto-online.de/ueber-netto/Online-Prospekte.chtm/' + market, + description = 'PDF der neuen Netto Angebote für den Laden um die Ecke.', + content = content) + response = Response(xml, mimetype='text/xml') + response.headers['Access-Control-Allow-Origin'] = '*' + return response + +@app.route("/zdf/<path:feed>") +def filterZDFFeed(feed): + title, url, description, content = zdf(feed) + xml = buildRSS( + title = title, + url = url, + description = description, + content = content) + response = Response(xml, mimetype='text/xml') + response.headers['Access-Control-Allow-Origin'] = '*' + return response + + +if __name__ == '__main__': + logging.basicConfig(filename='./main.log', level=logging.INFO) + + app.config['TEMPLATES_AUTO_RELOAD'] = True + app.run(threaded=True) + |