-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
103 lines (71 loc) · 2.63 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
from flask import Flask, Response, render_template, request
from getInfo import *
app = Flask(__name__)
@app.route("/")
def index():
years = getAllYears()
return render_template("home.html", years=years)
meetingsPerPage = 15
@app.route("/year/<year>")
def year(year):
meetings = retrieveMeetingsFromDatabase(int(year))
years = getAllYears()
pages = pagify(meetings)
page = int(request.args.get("page", 1))
pageMeetings = pages[page-1]
print(years)
return render_template("meetings.html", meetings=pageMeetings, pageNum=page, pageCount=len(pages), title=year, years=years, rss="all")
@app.route("/search")
def search():
years = getAllYears()
return render_template("search.html", years=years)
@app.route("/search/<strterms>")
def retrieve(strterms):
terms = strterms.split(",")
meetings = searchForTerm(terms)
years = getAllYears()
pages = pagify(meetings)
page = int(request.args.get("page", 1))
pageMeetings = pages[page-1]
return render_template("meetings.html", meetings=pageMeetings, pageNum=page, pageCount=len(pages), title="Terms: " + strterms, years=years, rss=strterms)
@app.route("/updateMonth")
def updateMonth():
message = getMonthMeetings()
return "<p>thanks for updating me!</p>" + message
@app.route("/update")
def update():
message = getPastMeetings()
return "<p>thanks for updating me!</p>" + message
@app.route("/rss/all")
def allRss():
meetings = getRecentMeetings()
items = arrangeRss(meetings)
xml = '''
<rss version = "2.0">
<channel>
<title> Unofficial Records of YEG City Council | All</title>
<link> https://yegrecords.glitch.me </link>
<description>Parses contents of Edmonton City Council Meeting Minutes found here: https://pub-edmonton.escribemeetings.com.</description>
''' + items + '''
</channel>
</rss>
'''
return Response(xml, mimetype='text/xml')
@app.route("/rss/<strterm>")
def customRss(strterm):
terms = strterm.split(",")
meetings = searchForTerm(terms)[0:10]
items = arrangeRss(meetings)
xml = '''
<rss version = "2.0">
<channel>
<title> Unofficial Records of YEG City Council | ''' + strterm + '''</title>
<link> https://yegrecords.glitch.me </link>
<description>Parses contents of Edmonton City Council Meeting Minutes found here: https://pub-edmonton.escribemeetings.com. This is a custom feed which only includes meetings with mention of these terms: ''' + strterm + '''</description>
''' + items + '''
</channel>
</rss>
'''
return Response(xml, mimetype='text/xml')
if __name__ == "__main__":
app.run(debug=True)