diff options
-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__': |