-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.py
158 lines (128 loc) · 4.78 KB
/
main.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
from flask import Flask, render_template, request
from core import feedcore
app = Flask(__name__)
@app.errorhandler(404)
def page_not_found(e):
return render_template("error.html", not_found=404)
@app.errorhandler(500)
def server_error(e):
return render_template("error.html", server_error=500)
@app.route("/sw.js")
def sw():
return app.send_static_file("sw.js")
@app.route("/robots.txt")
def robots():
return app.send_static_file("robots.txt")
@app.route("/general", methods=["GET"])
def general():
filter_feed = request.args.get("filter", default="*", type=str)
data_keys = feedcore.read_data("general")
data_keys = [item["name"] for item in data_keys]
if filter_feed == "*":
data = feedcore.all_feed(True)
return render_template("general.html", allfeed=data, feeder_sites=data_keys)
else:
for item in feedcore.read_data("general"):
if item["name"] == filter_feed:
data = feedcore.feed(item["link"])
return render_template(
"general.html",
allfeed=data,
filterfeed=filter_feed,
feeder_sites=data_keys,
filterfeed_link=item["web"],
)
return render_template("error.html", server_error=500)
@app.route("/news", methods=["GET"])
def news_feed():
filter_feed = request.args.get("filter", default="*", type=str)
data_keys = feedcore.read_data("news")
data_keys = [item["name"] for item in data_keys]
if filter_feed == "*":
data = feedcore.news_feed(True)
return render_template("news.html", news_feed_data=data, feeder_sites=data_keys)
else:
for item in feedcore.read_data("news"):
if item["name"] == filter_feed:
data = feedcore.feed(item["link"])
return render_template(
"news.html",
news_feed_data=data,
feeder_sites=data_keys,
filterfeed=filter_feed,
filterfeed_link=item["web"],
)
return render_template("error.html", server_error=500)
@app.route("/podcasts", methods=["GET"])
def podcast():
filter_feed = request.args.get("filter", default="*", type=str)
data_keys = feedcore.read_data("podcasts")
data_keys = [item["name"] for item in data_keys]
if filter_feed == "*":
data = feedcore.podcasts_feeds(True)
print(len(data))
return render_template(
"podcast.html", podcast_feed=data, feeder_sites=data_keys
)
else:
for item in feedcore.read_data("podcasts"):
if item["name"] == filter_feed:
data = feedcore.feed(item["link"])
return render_template(
"podcast.html",
podcast_feed=data,
feeder_sites=data_keys,
filterfeed=filter_feed,
filterfeed_link=item["web"],
)
return render_template("error.html", server_error=500)
@app.route("/newsletters", methods=["GET"])
def newsletter():
filter_feed = request.args.get("filter", default="*", type=str)
data_keys = feedcore.read_data("newsletters")
data_keys = [item["name"] for item in data_keys]
if filter_feed == "*":
data = feedcore.newsletters_feeds(True)
return render_template(
"newsletter.html", newsletter_feed=data, feeder_sites=data_keys
)
else:
for item in feedcore.read_data("newsletters"):
if item["name"] == filter_feed:
data = feedcore.feed(item["link"])
return render_template(
"newsletter.html",
newsletter_feed=data,
feeder_sites=data_keys,
filterfeed=filter_feed,
filterfeed_link=item["web"],
)
return render_template("error.html", server_error=500)
@app.route("/feeders")
def feeder_sites_info():
feed_sites = feedcore.read_data("general")
news_sites = feedcore.read_data("news")
podcasts_sites = feedcore.read_data("podcasts")
newsletter_feeds = feedcore.read_data("newsletters")
return render_template(
"feeders.html",
feed_sites=feed_sites,
news_sites=news_sites,
podcasts_sites=podcasts_sites,
newsletter_feeds=newsletter_feeds,
total=len(feed_sites)
+ len(podcasts_sites)
+ len(newsletter_feeds)
+ len(news_sites),
)
@app.route("/")
def home():
return render_template("home.html")
@app.route("/support")
def support():
return render_template("support.html")
@app.route("/feedback")
def feedback():
return render_template("feedback.html")
if __name__ == "__main__":
app.run(port=8001)