From 9fff75d7016b29715c2413febf6f86d7f444f52c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gl=C3=BCpker?= Date: Sun, 9 May 2021 20:15:36 +0200 Subject: Unify methods --- webapp.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'webapp.py') diff --git a/webapp.py b/webapp.py index 332cfc6..62a1bdf 100755 --- a/webapp.py +++ b/webapp.py @@ -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/") 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/") # def feedTelegram(account): @@ -55,17 +61,12 @@ def feedTwitter(account): @app.route("/netto/") 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/") 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__': -- cgit v1.2.3