diff options
author | André Glüpker <git@wgmd.de> | 2021-05-09 20:15:36 +0200 |
---|---|---|
committer | André Glüpker <git@wgmd.de> | 2021-05-09 20:23:18 +0200 |
commit | 9fff75d7016b29715c2413febf6f86d7f444f52c (patch) | |
tree | fdb81e5617e355eda2ba3daba90d61cacaaf5d9f /webapp.py | |
parent | 93f3613dab38125d9ae7d5e74498c5395ac80ab0 (diff) | |
download | rss-feeds-9fff75d7016b29715c2413febf6f86d7f444f52c.tar.gz rss-feeds-9fff75d7016b29715c2413febf6f86d7f444f52c.tar.bz2 rss-feeds-9fff75d7016b29715c2413febf6f86d7f444f52c.zip |
Unify methods
Diffstat (limited to 'webapp.py')
-rwxr-xr-x | webapp.py | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -25,20 +25,26 @@ app = Flask(__name__) app.secret_key = "NMcgoB.0wd+$.KVKj!F{3>U{%BBUVhL=7=5$:46rQH$Q{enCuU" +def rssResponse(data): + rss = buildRSS(data) + response = Response(rss, mimetype='text/xml') + response.headers['Access-Control-Allow-Origin'] = '*' + return response + + @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): - xml = buildRSS(twitter(account)) - response = Response(xml, mimetype='text/xml') - response.headers['Access-Control-Allow-Origin'] = '*' - return response + return rssResponse(twitter(account)) # @app.route("/telegram/<account>") # def feedTelegram(account): @@ -55,17 +61,12 @@ def feedTwitter(account): @app.route("/netto/<market>") def feedNetto(market): - xml = buildRSS(netto(market)) - response = Response(xml, mimetype='text/xml') - response.headers['Access-Control-Allow-Origin'] = '*' - return response + return rssResponse(netto(market)) + @app.route("/zdf/<path:feed>") def filterZDFFeed(feed): - xml = buildRSS(zdf(feed)) - response = Response(xml, mimetype='text/xml') - response.headers['Access-Control-Allow-Origin'] = '*' - return response + return rssResponse(zdf(feed)) if __name__ == '__main__': |