#!/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/") def feedTwitter(account): xml = buildRSS(twitter(account)) response = Response(xml, mimetype='text/xml') response.headers['Access-Control-Allow-Origin'] = '*' return response # @app.route("/telegram/") # 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/") def feedNetto(market): xml = buildRSS(netto(market)) response = Response(xml, mimetype='text/xml') response.headers['Access-Control-Allow-Origin'] = '*' return response @app.route("/zdf/") def filterZDFFeed(feed): xml = buildRSS(zdf(feed)) 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)