1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#!/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"
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):
return rssResponse(twitter(account))
# @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):
return rssResponse(netto(market))
@app.route("/zdf/<path:feed>")
def filterZDFFeed(feed):
return rssResponse(zdf(feed))
if __name__ == '__main__':
logging.basicConfig(filename='./main.log', level=logging.INFO)
app.config['TEMPLATES_AUTO_RELOAD'] = True
app.run(threaded=True)
|